summaryrefslogtreecommitdiffstats
path: root/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs
blob: 131f8d999d8781d5411514447ad15edc7ce8a4e6 (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
#![feature(impl_trait_in_assoc_type)]

trait Foo<T> {
    type Assoc;

    fn test() -> u32;
}

struct DefinesOpaque;
impl Foo<DefinesOpaque> for () {
    type Assoc = impl Sized;

    // This test's return type is `u32`, *not* the opaque that is defined above.
    // Previously we were only checking that the self type of the assoc matched,
    // but this doesn't account for other impls with different trait substs.
    fn test() -> <() as Foo<NoOpaques>>::Assoc {
        let _: <Self as Foo<DefinesOpaque>>::Assoc = "";
        //~^ ERROR mismatched types

        1
    }
}

struct NoOpaques;
impl Foo<NoOpaques> for () {
    type Assoc = u32;

    fn test() -> u32 {
        1
    }
}

fn main() {}