]> git.lizzy.rs Git - rust.git/blob - tests/ui/structs/struct-path-associated-type.rs
Auto merge of #106827 - alexcrichton:update-llvm-to-15.0.7, r=cuviper
[rust.git] / tests / ui / structs / struct-path-associated-type.rs
1 struct S;
2
3 trait Tr {
4     type A;
5 }
6
7 impl Tr for S {
8     type A = S;
9 }
10
11 fn f<T: Tr>() {
12     let s = T::A {};
13     //~^ ERROR expected struct, variant or union type, found associated type
14     let z = T::A::<u8> {};
15     //~^ ERROR expected struct, variant or union type, found associated type
16     //~| ERROR this associated type takes 0 generic arguments but 1 generic argument was supplied
17     match S {
18         T::A {} => {}
19         //~^ ERROR expected struct, variant or union type, found associated type
20     }
21 }
22
23 fn g<T: Tr<A = S>>() {
24     let s = T::A {}; // OK
25     let z = T::A::<u8> {}; //~ ERROR this associated type takes 0 generic arguments but 1 generic argument was supplied
26     match S {
27         T::A {} => {} // OK
28     }
29 }
30
31 fn main() {
32     let s = S::A {}; //~ ERROR ambiguous associated type
33     let z = S::A::<u8> {}; //~ ERROR ambiguous associated type
34     match S {
35         S::A {} => {} //~ ERROR ambiguous associated type
36     }
37 }