about summary refs log tree commit diff
path: root/tests/ui/impl-trait/associated-type-undefine.rs
blob: 895525960fc1ab2a592fc99a5fec92f0e5edfd9f (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
#![feature(impl_trait_in_assoc_type)]

trait Foo: Sized {
    type Bar;
    type Gat<T: Foo>;
    fn foo(self) -> (<Self as Foo>::Gat<u32>, <Self as Foo>::Gat<Self>);
}

impl Foo for u32 {
    type Bar = ();
    type Gat<T: Foo> = ();
    fn foo(self) -> (<Self as Foo>::Gat<u32>, <Self as Foo>::Gat<Self>) {
        ((), ())
    }
}

impl Foo for () {
    type Bar = impl Sized;
    //~^ ERROR: unconstrained opaque type
    type Gat<T: Foo> = <T as Foo>::Bar;
    // Because we encounter `Gat<u32>` first, we never walk into another `Gat`
    // again, thus missing the opaque type that we could be defining.
    fn foo(self) -> (<Self as Foo>::Gat<u32>, <Self as Foo>::Gat<Self>) {
        ((), ())
        //~^ ERROR: mismatched types
    }
}

fn main() {}