use deeply_normalize
for assumed_wf_types
This commit is contained in:
parent
d2c7449189
commit
5378f07d64
10 changed files with 112 additions and 52 deletions
|
@ -224,7 +224,8 @@ fn check_opaque(tcx: TyCtxt<'_>, id: hir::ItemId) {
|
|||
if check_opaque_for_cycles(tcx, item.owner_id.def_id, substs, span, &origin).is_err() {
|
||||
return;
|
||||
}
|
||||
check_opaque_meets_bounds(tcx, item.owner_id.def_id, span, &origin);
|
||||
|
||||
let _ = check_opaque_meets_bounds(tcx, item.owner_id.def_id, span, &origin);
|
||||
}
|
||||
|
||||
/// Checks that an opaque type does not use `Self` or `T::Foo` projections that would result
|
||||
|
@ -395,7 +396,7 @@ fn check_opaque_meets_bounds<'tcx>(
|
|||
def_id: LocalDefId,
|
||||
span: Span,
|
||||
origin: &hir::OpaqueTyOrigin,
|
||||
) {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let defining_use_anchor = match *origin {
|
||||
hir::OpaqueTyOrigin::FnReturn(did) | hir::OpaqueTyOrigin::AsyncFn(did) => did,
|
||||
hir::OpaqueTyOrigin::TyAlias { .. } => tcx.impl_trait_parent(def_id),
|
||||
|
@ -429,10 +430,10 @@ fn check_opaque_meets_bounds<'tcx>(
|
|||
Ok(()) => {}
|
||||
Err(ty_err) => {
|
||||
let ty_err = ty_err.to_string(tcx);
|
||||
tcx.sess.delay_span_bug(
|
||||
return Err(tcx.sess.delay_span_bug(
|
||||
span,
|
||||
format!("could not unify `{hidden_ty}` with revealed type:\n{ty_err}"),
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -447,7 +448,8 @@ fn check_opaque_meets_bounds<'tcx>(
|
|||
// version.
|
||||
let errors = ocx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
let guar = infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
return Err(guar);
|
||||
}
|
||||
match origin {
|
||||
// Checked when type checking the function containing them.
|
||||
|
@ -461,14 +463,15 @@ fn check_opaque_meets_bounds<'tcx>(
|
|||
if tcx.def_kind(tcx.parent(def_id.to_def_id())) == DefKind::OpaqueTy => {}
|
||||
// Can have different predicates to their defining use
|
||||
hir::OpaqueTyOrigin::TyAlias { .. } => {
|
||||
let wf_tys = ocx.assumed_wf_types(param_env, span, def_id);
|
||||
let wf_tys = ocx.assumed_wf_types_and_report_errors(param_env, def_id)?;
|
||||
let implied_bounds = infcx.implied_bounds_tys(param_env, def_id, wf_tys);
|
||||
let outlives_env = OutlivesEnvironment::with_bounds(param_env, implied_bounds);
|
||||
let _ = ocx.resolve_regions_and_report_errors(defining_use_anchor, &outlives_env);
|
||||
ocx.resolve_regions_and_report_errors(defining_use_anchor, &outlives_env)?;
|
||||
}
|
||||
}
|
||||
// Clean up after ourselves
|
||||
let _ = infcx.take_opaque_types();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn is_enum_of_nonnullable_ptr<'tcx>(
|
||||
|
|
|
@ -2121,7 +2121,7 @@ pub(super) fn check_type_bounds<'tcx>(
|
|||
_ => bug!(),
|
||||
}
|
||||
};
|
||||
let assumed_wf_types = ocx.assumed_wf_types(param_env, impl_ty_span, impl_ty_def_id);
|
||||
let assumed_wf_types = ocx.assumed_wf_types_and_report_errors(param_env, impl_ty_def_id)?;
|
||||
|
||||
let normalize_cause = ObligationCause::new(
|
||||
impl_ty_span,
|
||||
|
|
|
@ -105,7 +105,12 @@ pub(super) fn enter_wf_checking_ctxt<'tcx, F>(
|
|||
}
|
||||
f(&mut wfcx);
|
||||
|
||||
let assumed_wf_types = wfcx.ocx.assumed_wf_types(param_env, span, body_def_id);
|
||||
let assumed_wf_types = match wfcx.ocx.assumed_wf_types_and_report_errors(param_env, body_def_id)
|
||||
{
|
||||
Ok(wf_types) => wf_types,
|
||||
Err(_guar) => return,
|
||||
};
|
||||
|
||||
let implied_bounds = infcx.implied_bounds_tys(param_env, body_def_id, assumed_wf_types);
|
||||
|
||||
let errors = wfcx.select_all_or_error();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue