Auto merge of #114586 - oli-obk:patch_tait_rpit_order_check, r=lcnr,compiler-errors
Bubble up opaque <eq> opaque operations instead of picking an order In case we are in `Bubble` mode (meaning every opaque type that is defined in the current crate is treated as if it were in its defining scope), we don't try to register an opaque type as the hidden type of another opaque type, but instead bubble up an obligation to equate them at the query caller site. Usually that means we have a `DefiningAnchor::Bind` and thus can reliably figure out whether an opaque type is in its defining scope. Where we can't, we'll error out, so the default is sound. With this change we start using `AliasTyEq` predicates in the old solver, too. fixes https://github.com/rust-lang/rust/issues/108498 But also regresses `tests/ui/impl-trait/anon_scope_creep.rs`. Our use of `Bubble` for `check_opaque_type_well_formed` is going to keep biting us. r? `@lcnr` `@compiler-errors`
This commit is contained in:
commit
e2b3676733
8 changed files with 128 additions and 21 deletions
|
@ -328,19 +328,26 @@ fn check_opaque_type_well_formed<'tcx>(
|
|||
|
||||
// Require that the hidden type actually fulfills all the bounds of the opaque type, even without
|
||||
// the bounds that the function supplies.
|
||||
let opaque_ty = Ty::new_opaque(tcx, def_id.to_def_id(), identity_args);
|
||||
ocx.eq(&ObligationCause::misc(definition_span, def_id), param_env, opaque_ty, definition_ty)
|
||||
.map_err(|err| {
|
||||
infcx
|
||||
.err_ctxt()
|
||||
.report_mismatched_types(
|
||||
&ObligationCause::misc(definition_span, def_id),
|
||||
opaque_ty,
|
||||
definition_ty,
|
||||
err,
|
||||
)
|
||||
.emit()
|
||||
})?;
|
||||
let mut obligations = vec![];
|
||||
infcx
|
||||
.insert_hidden_type(
|
||||
OpaqueTypeKey { def_id, args: identity_args },
|
||||
&ObligationCause::misc(definition_span, def_id),
|
||||
param_env,
|
||||
definition_ty,
|
||||
true,
|
||||
&mut obligations,
|
||||
)
|
||||
.unwrap();
|
||||
infcx.add_item_bounds_for_hidden_type(
|
||||
def_id.to_def_id(),
|
||||
identity_args,
|
||||
ObligationCause::misc(definition_span, def_id),
|
||||
param_env,
|
||||
definition_ty,
|
||||
&mut obligations,
|
||||
);
|
||||
ocx.register_obligations(obligations);
|
||||
|
||||
// Require the hidden type to be well-formed with only the generics of the opaque type.
|
||||
// Defining use functions may have more bounds than the opaque type, which is ok, as long as the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue