提交 4dbf9ba0 编写于 作者: L lcnr

outside of borrowck, do not provide an implicit_region_bound

see comment added to the field in `VerifyBoundCx`.
上级 9cf699d2
......@@ -23,7 +23,7 @@ pub(crate) struct ConstraintConversion<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
universal_regions: &'a UniversalRegions<'tcx>,
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
implicit_region_bound: Option<ty::Region<'tcx>>,
implicit_region_bound: ty::Region<'tcx>,
param_env: ty::ParamEnv<'tcx>,
locations: Locations,
span: Span,
......@@ -36,7 +36,7 @@ pub(crate) fn new(
infcx: &'a InferCtxt<'a, 'tcx>,
universal_regions: &'a UniversalRegions<'tcx>,
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
implicit_region_bound: Option<ty::Region<'tcx>>,
implicit_region_bound: ty::Region<'tcx>,
param_env: ty::ParamEnv<'tcx>,
locations: Locations,
span: Span,
......@@ -120,7 +120,7 @@ pub(super) fn convert(&mut self, query_constraint: &QueryOutlivesConstraint<'tcx
&mut *self,
tcx,
region_bound_pairs,
implicit_region_bound,
Some(implicit_region_bound),
param_env,
)
.type_must_outlive(origin, t1, r2);
......
......@@ -61,7 +61,7 @@ pub(crate) struct CreateResult<'tcx> {
pub(crate) fn create<'tcx>(
infcx: &InferCtxt<'_, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
implicit_region_bound: Option<ty::Region<'tcx>>,
implicit_region_bound: ty::Region<'tcx>,
universal_regions: &Rc<UniversalRegions<'tcx>>,
constraints: &mut MirTypeckRegionConstraints<'tcx>,
) -> CreateResult<'tcx> {
......@@ -223,7 +223,7 @@ struct UniversalRegionRelationsBuilder<'this, 'tcx> {
infcx: &'this InferCtxt<'this, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
universal_regions: Rc<UniversalRegions<'tcx>>,
implicit_region_bound: Option<ty::Region<'tcx>>,
implicit_region_bound: ty::Region<'tcx>,
constraints: &'this mut MirTypeckRegionConstraints<'tcx>,
// outputs:
......
......@@ -230,7 +230,7 @@ pub(crate) fn normalize_and_add_constraints(&mut self, t: Ty<'tcx>) -> Fallible<
self.infcx,
&self.borrowck_context.universal_regions,
&self.region_bound_pairs,
Some(self.implicit_region_bound),
self.implicit_region_bound,
self.param_env,
Locations::All(DUMMY_SP),
DUMMY_SP,
......
......@@ -157,7 +157,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
} = free_region_relations::create(
infcx,
param_env,
Some(implicit_region_bound),
implicit_region_bound,
universal_regions,
&mut constraints,
);
......@@ -1142,7 +1142,7 @@ fn push_region_constraints(
self.infcx,
self.borrowck_context.universal_regions,
self.region_bound_pairs,
Some(self.implicit_region_bound),
self.implicit_region_bound,
self.param_env,
locations,
locations.span(self.body),
......
......@@ -141,9 +141,6 @@ pub fn take_registered_region_obligations(&self) -> Vec<(hir::HirId, RegionOblig
/// `('a, K)` in this list tells us that the bounds in scope
/// indicate that `K: 'a`, where `K` is either a generic
/// parameter like `T` or a projection like `T::Item`.
/// - `implicit_region_bound`: if some, this is a region bound
/// that is considered to hold for all type parameters (the
/// function body).
/// - `param_env` is the parameter environment for the enclosing function.
/// - `body_id` is the body-id whose region obligations are being
/// processed.
......@@ -151,7 +148,6 @@ pub fn take_registered_region_obligations(&self) -> Vec<(hir::HirId, RegionOblig
pub fn process_registered_region_obligations(
&self,
region_bound_pairs_map: &FxHashMap<hir::HirId, RegionBoundPairs<'tcx>>,
implicit_region_bound: Option<ty::Region<'tcx>>,
param_env: ty::ParamEnv<'tcx>,
) {
assert!(
......@@ -170,13 +166,8 @@ pub fn process_registered_region_obligations(
let sup_type = self.resolve_vars_if_possible(sup_type);
if let Some(region_bound_pairs) = region_bound_pairs_map.get(&body_id) {
let outlives = &mut TypeOutlives::new(
self,
self.tcx,
&region_bound_pairs,
implicit_region_bound,
param_env,
);
let outlives =
&mut TypeOutlives::new(self, self.tcx, &region_bound_pairs, None, param_env);
outlives.type_must_outlive(origin, sup_type, sub_region);
} else {
self.tcx.sess.delay_span_bug(
......
......@@ -16,6 +16,11 @@
pub struct VerifyBoundCx<'cx, 'tcx> {
tcx: TyCtxt<'tcx>,
region_bound_pairs: &'cx RegionBoundPairs<'tcx>,
/// During borrowck, if there are no outlives bounds on a generic
/// parameter `T`, we assume that `T: 'in_fn_body` holds.
///
/// Outside of borrowck the only way to prove `T: '?0` is by
/// setting `'?0` to `'empty`.
implicit_region_bound: Option<ty::Region<'tcx>>,
param_env: ty::ParamEnv<'tcx>,
}
......
......@@ -220,7 +220,7 @@ pub fn find_auto_trait_generics<A>(
.map(|&(id, _)| (id, vec![]))
.collect();
infcx.process_registered_region_obligations(&body_id_map, None, full_env);
infcx.process_registered_region_obligations(&body_id_map, full_env);
let region_data = infcx
.inner
......
......@@ -407,11 +407,7 @@ fn resolve_negative_obligation<'cx, 'tcx>(
// function bodies with closures).
outlives_env.save_implied_bounds(CRATE_HIR_ID);
infcx.process_registered_region_obligations(
outlives_env.region_bound_pairs_map(),
Some(tcx.lifetimes.re_root_empty),
param_env,
);
infcx.process_registered_region_obligations(outlives_env.region_bound_pairs_map(), param_env);
let errors = infcx.resolve_regions(region_context, &outlives_env);
......
......@@ -366,7 +366,6 @@ fn visit_region_obligations(&mut self, hir_id: hir::HirId) {
fn resolve_regions_and_report_errors(&self) {
self.infcx.process_registered_region_obligations(
self.outlives_environment.region_bound_pairs_map(),
Some(self.tcx.lifetimes.re_root_empty),
self.param_env,
);
......
......@@ -596,13 +596,7 @@ fn ty_known_to_outlive<'tcx>(
) -> bool {
resolve_regions_with_wf_tys(tcx, id, param_env, &wf_tys, |infcx, region_bound_pairs| {
let origin = infer::RelateParamBound(DUMMY_SP, ty, None);
let outlives = &mut TypeOutlives::new(
infcx,
tcx,
region_bound_pairs,
Some(infcx.tcx.lifetimes.re_root_empty),
param_env,
);
let outlives = &mut TypeOutlives::new(infcx, tcx, region_bound_pairs, None, param_env);
outlives.type_must_outlive(origin, ty, region);
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册