X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_typeck%2Fsrc%2Fcheck%2Fwfcheck.rs;h=8396cb1ae0aab1fef56c2c0213077fb18b0678f5;hb=d037f1843e9472d547dc22edbfb18788174c0754;hp=2ac183b504e0560d012fcfe44836d3f2c2be54a9;hpb=4fe666ee64d9f2a73571f0ab74a29cd30190573e;p=rust.git diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index 2ac183b504e..8396cb1ae0a 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -1,5 +1,5 @@ -use crate::check::regionck::OutlivesEnvironmentExt; use crate::constrained_generic_params::{identify_constrained_generic_params, Parameter}; +use crate::outlives::outlives_bounds::InferCtxtExt as _; use rustc_ast as ast; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed}; @@ -90,15 +90,7 @@ pub(super) fn enter_wf_checking_ctxt<'tcx, F>( tcx.infer_ctxt().enter(|ref infcx| { let ocx = ObligationCtxt::new(infcx); - let assumed_wf_types = tcx.assumed_wf_types(body_def_id); - let mut implied_bounds = FxHashSet::default(); - let cause = ObligationCause::misc(span, body_id); - for ty in assumed_wf_types { - implied_bounds.insert(ty); - let normalized = ocx.normalize(cause.clone(), param_env, ty); - implied_bounds.insert(normalized); - } - let implied_bounds = implied_bounds; + let assumed_wf_types = ocx.assumed_wf_types(param_env, span, body_def_id); let mut wfcx = WfCheckingCtxt { ocx, span, body_id, param_env }; @@ -112,8 +104,10 @@ pub(super) fn enter_wf_checking_ctxt<'tcx, F>( return; } - let mut outlives_environment = OutlivesEnvironment::new(param_env); - outlives_environment.add_implied_bounds(infcx, implied_bounds, body_id); + 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); }) } @@ -702,8 +696,11 @@ 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); - outlives_environment.add_implied_bounds(&infcx, wf_tys.clone(), id); + let outlives_environment = OutlivesEnvironment::with_bounds( + param_env, + Some(&infcx), + infcx.implied_bounds_tys(param_env, id, wf_tys.iter().map(|ty| *ty)), + ); let region_bound_pairs = outlives_environment.region_bound_pairs(); add_constraints(&infcx, region_bound_pairs);