]> git.lizzy.rs Git - rust.git/blob - tests/ui/ufcs/ufcs-partially-resolved.rs
Rollup merge of #106766 - GuillaumeGomez:rm-stripper-dead-code, r=notriddle
[rust.git] / tests / ui / ufcs / ufcs-partially-resolved.rs
1 #![feature(associated_type_defaults)]
2
3 trait Tr {
4     type Y = u16;
5     fn Y() {}
6 }
7 impl Tr for u8 {}
8
9 trait Dr {
10     type X = u16;
11     fn Z() {}
12 }
13 impl Dr for u8 {}
14
15 enum E { Y }
16 type A = u32;
17
18 fn main() {
19     let _: <u8 as Tr>::N; //~ ERROR cannot find associated type `N` in trait `Tr`
20     let _: <u8 as E>::N; //~ ERROR cannot find associated type `N` in enum `E`
21     let _: <u8 as A>::N; //~ ERROR cannot find associated type `N` in `A`
22     <u8 as Tr>::N; //~ ERROR cannot find method or associated constant `N` in trait `Tr`
23     <u8 as E>::N; //~ ERROR cannot find method or associated constant `N` in enum `E`
24     <u8 as A>::N; //~ ERROR cannot find method or associated constant `N` in `A`
25     let _: <u8 as Tr>::Y; // OK
26     let _: <u8 as E>::Y; //~ ERROR expected associated type, found variant `E::Y`
27     <u8 as Tr>::Y; // OK
28     <u8 as E>::Y; //~ ERROR expected method or associated constant, found unit variant `E::Y`
29
30     let _: <u8 as Tr>::N::NN; //~ ERROR cannot find associated type `N` in trait `Tr`
31     let _: <u8 as E>::N::NN; //~ ERROR cannot find associated type `N` in enum `E`
32     let _: <u8 as A>::N::NN; //~ ERROR cannot find associated type `N` in `A`
33     <u8 as Tr>::N::NN; //~ ERROR cannot find associated type `N` in trait `Tr`
34     <u8 as E>::N::NN; //~ ERROR cannot find associated type `N` in enum `E`
35     <u8 as A>::N::NN; //~ ERROR cannot find associated type `N` in `A`
36     let _: <u8 as Tr>::Y::NN; //~ ERROR ambiguous associated type
37     let _: <u8 as E>::Y::NN; //~ ERROR expected associated type, found variant `E::Y`
38     <u8 as Tr>::Y::NN; //~ ERROR no associated item named `NN` found for type `u16`
39     <u8 as E>::Y::NN; //~ ERROR expected associated type, found variant `E::Y`
40
41     let _: <u8 as Tr::N>::NN; //~ ERROR cannot find associated type `NN` in `Tr::N`
42     let _: <u8 as E::N>::NN; //~ ERROR cannot find associated type `NN` in `E::N`
43     let _: <u8 as A::N>::NN; //~ ERROR cannot find associated type `NN` in `A::N`
44     <u8 as Tr::N>::NN; //~ ERROR cannot find method or associated constant `NN` in `Tr::N`
45     <u8 as E::N>::NN; //~ ERROR cannot find method or associated constant `NN` in `E::N`
46     <u8 as A::N>::NN; //~ ERROR cannot find method or associated constant `NN` in `A::N`
47     let _: <u8 as Tr::Y>::NN; //~ ERROR cannot find associated type `NN` in `Tr::Y`
48     let _: <u8 as E::Y>::NN; //~ ERROR failed to resolve: `Y` is a variant, not a module
49     <u8 as Tr::Y>::NN; //~ ERROR cannot find method or associated constant `NN` in `Tr::Y`
50     <u8 as E::Y>::NN; //~ ERROR failed to resolve: `Y` is a variant, not a module
51
52     let _: <u8 as Dr>::Z; //~ ERROR expected associated type, found associated function `Dr::Z`
53     <u8 as Dr>::X; //~ ERROR expected method or associated constant, found associated type `Dr::X`
54     let _: <u8 as Dr>::Z::N; //~ ERROR expected associated type, found associated function `Dr::Z`
55     <u8 as Dr>::X::N; //~ ERROR no associated item named `N` found for type `u16`
56 }