Skip to content

Commit a810b58

Browse files
Use DefiningAnchor::Bind in infer_opaque_definition_from_instantiation
1 parent 917b0b6 commit a810b58

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,18 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
278278
// HACK This bubble is required for this tests to pass:
279279
// nested-return-type2-tait2.rs
280280
// nested-return-type2-tait3.rs
281-
let infcx =
282-
self.tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).build();
281+
// FIXME(-Ztrait-solver=next): We probably should use `DefiningAnchor::Error`
282+
// and prepopulate this `InferCtxt` with known opaque values, rather than
283+
// using the `Bind` anchor here. For now it's fine.
284+
let infcx = self
285+
.tcx
286+
.infer_ctxt()
287+
.with_opaque_type_inference(if self.tcx.trait_solver_next() {
288+
DefiningAnchor::Bind(def_id)
289+
} else {
290+
DefiningAnchor::Bubble
291+
})
292+
.build();
283293
let ocx = ObligationCtxt::new(&infcx);
284294
// Require the hidden type to be well-formed with only the generics of the opaque type.
285295
// Defining use functions may have more bounds than the opaque type, which is ok, as long as the

tests/ui/type-alias-impl-trait/cross_inference.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// revisions: current next
2+
//[next] compile-flags: -Ztrait-solver=next
13
// check-pass
24

35
#![feature(type_alias_impl_trait)]

0 commit comments

Comments
 (0)