1
Fork 0

get rid of RefCell in TransitiveRelation

This commit is contained in:
SparrowLii 2022-07-25 11:06:22 +08:00
parent a9bb589cd6
commit 5d9e4d07fc
9 changed files with 179 additions and 118 deletions

View file

@ -401,8 +401,9 @@ fn compare_predicate_entailment<'tcx>(
// Finally, resolve all regions. This catches wily misuses of
// lifetime parameters.
let mut outlives_environment = OutlivesEnvironment::new(param_env);
let mut outlives_environment = OutlivesEnvironment::builder(param_env);
outlives_environment.add_implied_bounds(infcx, wf_tys, impl_m_hir_id);
let outlives_environment = outlives_environment.build();
infcx.check_region_obligations_and_report_errors(
impl_m.def_id.expect_local(),
&outlives_environment,
@ -1513,8 +1514,9 @@ pub fn check_type_bounds<'tcx>(
// Finally, resolve all regions. This catches wily misuses of
// lifetime parameters.
let mut outlives_environment = OutlivesEnvironment::new(param_env);
let mut outlives_environment = OutlivesEnvironment::builder(param_env);
outlives_environment.add_implied_bounds(&infcx, assumed_wf_types, impl_ty_hir_id);
let outlives_environment = outlives_environment.build();
infcx.check_region_obligations_and_report_errors(
impl_ty.def_id.expect_local(),
&outlives_environment,

View file

@ -1,7 +1,7 @@
use crate::outlives::outlives_bounds::InferCtxtExt as _;
use rustc_data_structures::fx::FxHashSet;
use rustc_hir as hir;
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
use rustc_infer::infer::outlives::env::OutlivesEnvironmentBuilder;
use rustc_infer::infer::InferCtxt;
use rustc_middle::ty::Ty;
@ -14,7 +14,7 @@ pub(crate) trait OutlivesEnvironmentExt<'tcx> {
);
}
impl<'tcx> OutlivesEnvironmentExt<'tcx> for OutlivesEnvironment<'tcx> {
impl<'tcx> OutlivesEnvironmentExt<'tcx> for OutlivesEnvironmentBuilder<'tcx> {
/// This method adds "implied bounds" into the outlives environment.
/// Implied bounds are outlives relationships that we can deduce
/// on the basis that certain types must be well-formed -- these are

View file

@ -104,8 +104,9 @@ pub(super) fn enter_wf_checking_ctxt<'tcx, F>(
return;
}
let mut outlives_environment = OutlivesEnvironment::new(param_env);
let mut outlives_environment = OutlivesEnvironment::builder(param_env);
outlives_environment.add_implied_bounds(infcx, assumed_wf_types, body_id);
let outlives_environment = outlives_environment.build();
infcx.check_region_obligations_and_report_errors(body_def_id, &outlives_environment);
})
}
@ -694,8 +695,9 @@ fn resolve_regions_with_wf_tys<'tcx>(
// region constraints get added and solved there and we need to test each
// call individually.
tcx.infer_ctxt().enter(|infcx| {
let mut outlives_environment = OutlivesEnvironment::new(param_env);
let mut outlives_environment = OutlivesEnvironment::builder(param_env);
outlives_environment.add_implied_bounds(&infcx, wf_tys.clone(), id);
let outlives_environment = outlives_environment.build();
let region_bound_pairs = outlives_environment.region_bound_pairs();
add_constraints(&infcx, region_bound_pairs);

View file

@ -166,8 +166,7 @@ fn get_impl_substs<'tcx>(
return None;
};
Some((impl1_substs, impl2_substs))
})
}
})}
/// Returns a list of all of the unconstrained subst of the given impl.
///