outside of borrowck, do not provide an implicit_region_bound
see comment added to the field in `VerifyBoundCx`.
This commit is contained in:
parent
9cf699d2ff
commit
4dbf9ba0ab
10 changed files with 18 additions and 33 deletions
|
@ -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 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
|
|||
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 @@ impl<'a, 'tcx> ConstraintConversion<'a, '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 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
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 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
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 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
|||
/// `('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 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
|||
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 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
|||
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,
|
||||
®ion_bound_pairs,
|
||||
implicit_region_bound,
|
||||
param_env,
|
||||
);
|
||||
let outlives =
|
||||
&mut TypeOutlives::new(self, self.tcx, ®ion_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 @@ use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt};
|
|||
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 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||
.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 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
|
|||
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);
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue