summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs
blob: fd5d0e3b1946e64442ccf44bb0f3d1f7b8465a28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// compile-flags: -Ztrait-solver=next

// check that when computing `alias-eq(<() as Foo<u16, T>>::Assoc, <() as Foo<?0, T>>::Assoc)`
//  we do not infer `?0 = u8` via the `for<STOP> (): Foo<u8, STOP>` impl or `?0 = u16` by
// relating substs as either could be a valid solution.

trait Foo<T, STOP> {
    type Assoc;
}

impl<STOP> Foo<u8, STOP> for ()
where
    (): Foo<u16, STOP>,
{
    type Assoc = <() as Foo<u16, STOP>>::Assoc;
}

impl Foo<u16, i8> for () {
    type Assoc = u8;
}

impl Foo<u16, i16> for () {
    type Assoc = u16;
}

fn output<T, U>() -> <() as Foo<T, U>>::Assoc
where
    (): Foo<T, U>,
{
    todo!()
}

fn incomplete<T>()
where
    (): Foo<u16, T>,
{
    // `<() as Foo<u16, STOP>>::Assoc == <() as Foo<_, STOP>>::Assoc`
    let _: <() as Foo<u16, T>>::Assoc = output::<_, T>();
    //~^ error: type annotations needed

    // let _: <() as Foo<u16, T>>::Assoc = output::<u8, T>(); // OK
    // let _: <() as Foo<u16, T>>::Assoc = output::<u16, T>(); // OK
}

fn main() {}