Change InferCtxtBuilder from enter to build
This commit is contained in:
@@ -91,29 +91,28 @@ pub(super) fn enter_wf_checking_ctxt<'tcx, F>(
|
||||
{
|
||||
let param_env = tcx.param_env(body_def_id);
|
||||
let body_id = tcx.hir().local_def_id_to_hir_id(body_def_id);
|
||||
tcx.infer_ctxt().enter(|ref infcx| {
|
||||
let ocx = ObligationCtxt::new(infcx);
|
||||
let infcx = &tcx.infer_ctxt().build();
|
||||
let ocx = ObligationCtxt::new(infcx);
|
||||
|
||||
let assumed_wf_types = ocx.assumed_wf_types(param_env, span, body_def_id);
|
||||
let assumed_wf_types = ocx.assumed_wf_types(param_env, span, body_def_id);
|
||||
|
||||
let mut wfcx = WfCheckingCtxt { ocx, span, body_id, param_env };
|
||||
let mut wfcx = WfCheckingCtxt { ocx, span, body_id, param_env };
|
||||
|
||||
if !tcx.features().trivial_bounds {
|
||||
wfcx.check_false_global_bounds()
|
||||
}
|
||||
f(&mut wfcx);
|
||||
let errors = wfcx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors, None, false);
|
||||
return;
|
||||
}
|
||||
if !tcx.features().trivial_bounds {
|
||||
wfcx.check_false_global_bounds()
|
||||
}
|
||||
f(&mut wfcx);
|
||||
let errors = wfcx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors, None, false);
|
||||
return;
|
||||
}
|
||||
|
||||
let implied_bounds = infcx.implied_bounds_tys(param_env, body_id, assumed_wf_types);
|
||||
let outlives_environment =
|
||||
OutlivesEnvironment::with_bounds(param_env, Some(infcx), implied_bounds);
|
||||
let implied_bounds = infcx.implied_bounds_tys(param_env, body_id, assumed_wf_types);
|
||||
let outlives_environment =
|
||||
OutlivesEnvironment::with_bounds(param_env, Some(infcx), implied_bounds);
|
||||
|
||||
infcx.check_region_obligations_and_report_errors(body_def_id, &outlives_environment);
|
||||
})
|
||||
infcx.check_region_obligations_and_report_errors(body_def_id, &outlives_environment);
|
||||
}
|
||||
|
||||
fn check_well_formed(tcx: TyCtxt<'_>, def_id: hir::OwnerId) {
|
||||
@@ -704,24 +703,23 @@ fn resolve_regions_with_wf_tys<'tcx>(
|
||||
// Unfortunately, we have to use a new `InferCtxt` each call, because
|
||||
// region constraints get added and solved there and we need to test each
|
||||
// call individually.
|
||||
tcx.infer_ctxt().enter(|infcx| {
|
||||
let outlives_environment = OutlivesEnvironment::with_bounds(
|
||||
param_env,
|
||||
Some(&infcx),
|
||||
infcx.implied_bounds_tys(param_env, id, wf_tys.clone()),
|
||||
);
|
||||
let region_bound_pairs = outlives_environment.region_bound_pairs();
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
let outlives_environment = OutlivesEnvironment::with_bounds(
|
||||
param_env,
|
||||
Some(&infcx),
|
||||
infcx.implied_bounds_tys(param_env, id, wf_tys.clone()),
|
||||
);
|
||||
let region_bound_pairs = outlives_environment.region_bound_pairs();
|
||||
|
||||
add_constraints(&infcx, region_bound_pairs);
|
||||
add_constraints(&infcx, region_bound_pairs);
|
||||
|
||||
let errors = infcx.resolve_regions(&outlives_environment);
|
||||
let errors = infcx.resolve_regions(&outlives_environment);
|
||||
|
||||
debug!(?errors, "errors");
|
||||
debug!(?errors, "errors");
|
||||
|
||||
// If we were able to prove that the type outlives the region without
|
||||
// an error, it must be because of the implied or explicit bounds...
|
||||
errors.is_empty()
|
||||
})
|
||||
// If we were able to prove that the type outlives the region without
|
||||
// an error, it must be because of the implied or explicit bounds...
|
||||
errors.is_empty()
|
||||
}
|
||||
|
||||
/// TypeVisitor that looks for uses of GATs like
|
||||
|
||||
Reference in New Issue
Block a user