-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};
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 };
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);
})
}
// 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);