diff --git a/tests/ui/traits/next-solver/alias-relate/transitive-inference.rs b/tests/ui/traits/next-solver/alias-relate/transitive-inference.rs new file mode 100644 index 000000000000..e41ea736e950 --- /dev/null +++ b/tests/ui/traits/next-solver/alias-relate/transitive-inference.rs @@ -0,0 +1,38 @@ +//@ revisions: old next +//@[next] compile-flags: -Znext-solver=globally +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ check-pass +// Regression test for trait-system-refactor-initiative#7 + +use std::marker::PhantomData; + +#[derive(Default)] +struct Foo(PhantomData<(T, U)>); + +trait Trait { + type Assoc; + + fn to_assoc(self) -> Self::Assoc; +} + +impl Trait for Foo { + type Assoc = Foo; + fn to_assoc(self) -> Self::Assoc { + Foo(PhantomData) + } +} +impl Trait for Foo { + type Assoc = Foo; + fn to_assoc(self) -> Self::Assoc { + Foo(PhantomData) + } +} + +#[allow(unused_assignments)] +fn main() { + let mut x: Foo<_, _> = Default::default(); + let mut assoc = x.to_assoc(); + assoc = Foo::(PhantomData); + assoc = Foo::<_, i32>(PhantomData); + x = assoc; +}