Skip to content

Commit 969f531

Browse files
fixup! Fix replacing supertrait aliases in ReplaceProjectionWith
1 parent 450853a commit 969f531

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Diff for: compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs

-1
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,6 @@ where
955955
// If there's more than one projection that we can unify here, then we
956956
// need to stall until inference constrains things so that there's only
957957
// one choice.
958-
// println!("ambiguity!");
959958
return Err(Ambiguous);
960959
}
961960

Diff for: tests/ui/traits/next-solver/supertrait-alias-4.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ compile-flags: -Znext-solver
2+
//@ check-pass
3+
4+
// Exercises the ambiguity that comes from replacing the associated types within the bounds
5+
// that are required for a `impl Trait for dyn Trait` built-in object impl to hold.
6+
7+
trait Sup<T> {
8+
type Assoc;
9+
}
10+
11+
trait Foo<A, B>: Sup<A, Assoc = A> + Sup<B, Assoc = B> {
12+
type Other: Bar<<Self as Sup<A>>::Assoc>;
13+
}
14+
15+
trait Bar<T> {}
16+
impl Bar<i32> for () {}
17+
18+
fn foo<A, B>(x: &(impl Foo<A, B> + ?Sized)) {}
19+
20+
fn main() {
21+
let x: &dyn Foo<_, _, Other = ()> = todo!();
22+
foo(x);
23+
let y: &dyn Foo<i32, u32, Other = ()> = x;
24+
}

0 commit comments

Comments
 (0)