Auto merge of #121796 - oli-obk:eager_opaque_checks3, r=lcnr

Make `DefiningAnchor::Bind` only store the opaque types that may be constrained, instead of the current infcx root item.

This makes `Bind` almost always be empty, so we can start forwarding it to queries, allowing us to remove `Bubble` entirely (not done in this PR)

The only behaviour change is in diagnostics.

r? `@lcnr` `@compiler-errors`
This commit is contained in:
bors 2024-03-11 19:01:15 +00:00
commit 4ccbb7dc95
48 changed files with 322 additions and 251 deletions

View file

@ -347,7 +347,7 @@ fn check_opaque_meets_bounds<'tcx>(
let infcx = tcx
.infer_ctxt()
.with_opaque_type_inference(DefiningAnchor::Bind(defining_use_anchor))
.with_opaque_type_inference(DefiningAnchor::bind(tcx, defining_use_anchor))
.build();
let ocx = ObligationCtxt::new(&infcx);
@ -1558,7 +1558,7 @@ pub(super) fn check_coroutine_obligations(
.ignoring_regions()
// Bind opaque types to type checking root, as they should have been checked by borrowck,
// but may show up in some cases, like when (root) obligations are stalled in the new solver.
.with_opaque_type_inference(DefiningAnchor::Bind(typeck.hir_owner.def_id))
.with_opaque_type_inference(DefiningAnchor::bind(tcx, typeck.hir_owner.def_id))
.build();
let mut fulfillment_cx = <dyn TraitEngine<'_>>::new(&infcx);