]>
Commit | Line | Data |
---|---|---|
32a655c1 SL |
1 | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
11 | #![feature(associated_type_defaults)] | |
12 | ||
13 | trait Tr { | |
14 | type Y = u16; | |
15 | fn Y() {} | |
16 | } | |
17 | impl Tr for u8 {} | |
18 | ||
19 | trait Dr { | |
20 | type X = u16; | |
21 | fn Z() {} | |
22 | } | |
23 | impl Dr for u8 {} | |
24 | ||
25 | enum E { Y } | |
26 | type A = u32; | |
27 | ||
28 | fn main() { | |
29 | let _: <u8 as Tr>::N; //~ ERROR cannot find associated type `N` in trait `Tr` | |
30 | let _: <u8 as E>::N; //~ ERROR cannot find associated type `N` in enum `E` | |
31 | let _: <u8 as A>::N; //~ ERROR cannot find associated type `N` in `A` | |
32 | <u8 as Tr>::N; //~ ERROR cannot find method or associated constant `N` in trait `Tr` | |
33 | <u8 as E>::N; //~ ERROR cannot find method or associated constant `N` in enum `E` | |
34 | <u8 as A>::N; //~ ERROR cannot find method or associated constant `N` in `A` | |
35 | let _: <u8 as Tr>::Y; // OK | |
36 | let _: <u8 as E>::Y; //~ ERROR expected associated type, found variant `E::Y` | |
37 | <u8 as Tr>::Y; // OK | |
38 | <u8 as E>::Y; //~ ERROR expected method or associated constant, found unit variant `E::Y` | |
39 | ||
40 | let _: <u8 as Tr>::N::NN; //~ ERROR cannot find associated type `N` in trait `Tr` | |
41 | let _: <u8 as E>::N::NN; //~ ERROR cannot find associated type `N` in enum `E` | |
42 | let _: <u8 as A>::N::NN; //~ ERROR cannot find associated type `N` in `A` | |
43 | <u8 as Tr>::N::NN; //~ ERROR cannot find associated type `N` in trait `Tr` | |
44 | <u8 as E>::N::NN; //~ ERROR cannot find associated type `N` in enum `E` | |
45 | <u8 as A>::N::NN; //~ ERROR cannot find associated type `N` in `A` | |
46 | let _: <u8 as Tr>::Y::NN; //~ ERROR ambiguous associated type | |
47 | let _: <u8 as E>::Y::NN; //~ ERROR expected associated type, found variant `E::Y` | |
48 | <u8 as Tr>::Y::NN; //~ ERROR no associated item named `NN` found for type `<u8 as Tr>::Y` | |
49 | <u8 as E>::Y::NN; //~ ERROR expected associated type, found variant `E::Y` | |
50 | ||
51 | let _: <u8 as Tr::N>::NN; //~ ERROR cannot find associated type `NN` in `Tr::N` | |
52 | let _: <u8 as E::N>::NN; //~ ERROR cannot find associated type `NN` in `E::N` | |
53 | let _: <u8 as A::N>::NN; //~ ERROR cannot find associated type `NN` in `A::N` | |
54 | <u8 as Tr::N>::NN; //~ ERROR cannot find method or associated constant `NN` in `Tr::N` | |
55 | <u8 as E::N>::NN; //~ ERROR cannot find method or associated constant `NN` in `E::N` | |
56 | <u8 as A::N>::NN; //~ ERROR cannot find method or associated constant `NN` in `A::N` | |
57 | let _: <u8 as Tr::Y>::NN; //~ ERROR cannot find associated type `NN` in `Tr::Y` | |
58 | let _: <u8 as E::Y>::NN; //~ ERROR failed to resolve. Not a module `Y` | |
59 | <u8 as Tr::Y>::NN; //~ ERROR cannot find method or associated constant `NN` in `Tr::Y` | |
60 | <u8 as E::Y>::NN; //~ ERROR failed to resolve. Not a module `Y` | |
61 | ||
62 | let _: <u8 as Dr>::Z; //~ ERROR expected associated type, found method `Dr::Z` | |
63 | <u8 as Dr>::X; //~ ERROR expected method or associated constant, found associated type `Dr::X` | |
64 | let _: <u8 as Dr>::Z::N; //~ ERROR expected associated type, found method `Dr::Z` | |
65 | <u8 as Dr>::X::N; //~ ERROR no associated item named `N` found for type `<u8 as Dr>::X` | |
66 | } |