]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/issue-21221-1.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / issue-21221-1.rs
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 mod mul1 {
12 pub trait Mul {}
13 }
14
15 mod mul2 {
16 pub trait Mul {}
17 }
18
19 mod mul3 {
20 enum Mul {
21 Yes,
22 No
23 }
24 }
25
26 mod mul4 {
27 type Mul = String;
28 }
29
30 mod mul5 {
31 struct Mul{
32 left_term: u32,
33 right_term: u32
34 }
35 }
36
37 #[derive(Debug)]
38 struct Foo;
39
40 // When we comment the next line:
41 //use mul1::Mul;
42
43 // BEFORE, we got the following error for the `impl` below:
44 // error: use of undeclared trait name `Mul` [E0405]
45 // AFTER, we get this message:
46 // error: trait `Mul` is not in scope.
47 // help: ...
48 // help: you can import several candidates into scope (`use ...;`):
49 // help: `mul1::Mul`
50 // help: `mul2::Mul`
51 // help: `std::ops::Mul`
52
53 impl Mul for Foo {
54 //~^ ERROR trait `Mul` is not in scope
55 //~| HELP `mul1::Mul`
56 //~| HELP `mul2::Mul`
57 //~| HELP `std::ops::Mul`
58 //~| HELP run `rustc --explain E0405` to see a detailed explanation
59 //~| HELP you can import several candidates into scope (`use ...;`):
60 }
61
62 // BEFORE, we got:
63 // error: use of undeclared type name `Mul` [E0412]
64 // AFTER, we get:
65 // error: type name `Mul` is not in scope. Maybe you meant:
66 // help: ...
67 // help: you can import several candidates into scope (`use ...;`):
68 // help: `mul1::Mul`
69 // help: `mul2::Mul`
70 // help: `mul3::Mul`
71 // help: `mul4::Mul`
72 // help: and 2 other candidates
73 fn getMul() -> Mul {
74 //~^ ERROR type name `Mul` is undefined or not in scope
75 //~| HELP `mul1::Mul`
76 //~| HELP `mul2::Mul`
77 //~| HELP `mul3::Mul`
78 //~| HELP `mul4::Mul`
79 //~| HELP and 2 other candidates
80 //~| HELP run `rustc --explain E0412` to see a detailed explanation
81 //~| HELP you can import several candidates into scope (`use ...;`):
82 }
83
84 // Let's also test what happens if the trait doesn't exist:
85 impl ThisTraitReallyDoesntExistInAnyModuleReally for Foo {
86 //~^ ERROR trait `ThisTraitReallyDoesntExistInAnyModuleReally` is not in scope
87 //~^^ HELP run `rustc --explain E0405` to see a detailed explanation
88 //~^^^ HELP no candidates by the name of `ThisTraitReallyDoesntExistInAnyModuleReally` found
89 }
90
91 // Let's also test what happens if there's just one alternative:
92 impl Div for Foo {
93 //~^ ERROR trait `Div` is not in scope
94 //~| HELP `use std::ops::Div;`
95 //~| HELP run `rustc --explain E0405` to see a detailed explanation
96 }
97
98 fn main() {
99 let foo = Foo();
100 println!("Hello, {:?}!", foo);
101 }