]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
1 | // Tests that methods that implement a trait cannot be invoked |
2 | // unless the trait is imported. | |
3 | ||
4 | mod Lib { | |
5 | pub trait TheTrait { | |
6 | fn the_fn(&self); | |
7 | } | |
8 | ||
9 | pub struct TheStruct; | |
10 | ||
11 | impl TheTrait for TheStruct { | |
12 | fn the_fn(&self) {} | |
13 | } | |
14 | } | |
15 | ||
16 | mod Import { | |
17 | // Trait is in scope here: | |
18 | use Lib::TheStruct; | |
19 | use Lib::TheTrait; | |
20 | ||
21 | fn call_the_fn(s: &TheStruct) { | |
22 | s.the_fn(); | |
23 | } | |
24 | } | |
25 | ||
26 | mod NoImport { | |
27 | // Trait is not in scope here: | |
28 | use Lib::TheStruct; | |
29 | ||
30 | fn call_the_fn(s: &TheStruct) { | |
0731742a | 31 | s.the_fn(); |
60c5eb7d | 32 | //~^ ERROR E0599 |
223e47cc LB |
33 | } |
34 | } | |
35 | ||
1a4d82fc | 36 | fn main() {} |