]> git.lizzy.rs Git - rust.git/blob - tests/ui/coherence/coherence_inherent.rs
Auto merge of #106853 - TimNN:undo-remap, r=oli-obk
[rust.git] / tests / ui / coherence / coherence_inherent.rs
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) {
31         s.the_fn();
32         //~^ ERROR E0599
33     }
34 }
35
36 fn main() {}