]> git.proxmox.com Git - rustc.git/blob - tests/ui/resolve/issue-21221-1.rs
New upstream version 1.74.1+dfsg1
[rustc.git] / tests / ui / resolve / issue-21221-1.rs
1 mod mul1 {
2 pub trait Mul {}
3 }
4
5 mod mul2 {
6 pub trait Mul {}
7 }
8
9 mod mul3 {
10 enum Mul {
11 Yes,
12 No
13 }
14 }
15
16 mod mul4 {
17 type Mul = String;
18 }
19
20 mod mul5 {
21 struct Mul{
22 left_term: u32,
23 right_term: u32
24 }
25 }
26
27 #[derive(Debug)]
28 struct Foo;
29
30 // When we comment the next line:
31 //use mul1::Mul;
32
33 // BEFORE, we got the following error for the `impl` below:
34 // error: use of undeclared trait name `Mul` [E0405]
35 // AFTER, we get this message:
36 // error: trait `Mul` is not in scope.
37 // help: ...
38 // help: you can import several candidates into scope (`use ...;`):
39 // help: `mul1::Mul`
40 // help: `mul2::Mul`
41 // help: `std::ops::Mul`
42
43 impl Mul for Foo {
44 //~^ ERROR cannot find trait `Mul`
45 }
46
47 // BEFORE, we got:
48 // error: use of undeclared type name `Mul` [E0412]
49 // AFTER, we get:
50 // error: type name `Mul` is not in scope. Maybe you meant:
51 // help: ...
52 // help: you can import several candidates into scope (`use ...;`):
53 // help: `mul1::Mul`
54 // help: `mul2::Mul`
55 // help: `mul3::Mul`
56 // help: `mul4::Mul`
57 // help: and 2 other candidates
58 fn getMul() -> Mul {
59 //~^ ERROR cannot find type `Mul`
60 }
61
62 // Let's also test what happens if the trait doesn't exist:
63 impl ThisTraitReallyDoesntExistInAnyModuleReally for Foo {
64 //~^ ERROR cannot find trait `ThisTraitReallyDoesntExistInAnyModuleReally`
65 }
66
67 // Let's also test what happens if there's just one alternative:
68 impl Div for Foo {
69 //~^ ERROR cannot find trait `Div`
70 }
71
72 fn main() {
73 let foo = Foo();
74 println!("Hello, {:?}!", foo);
75 }