]> git.lizzy.rs Git - rust.git/blob - src/librustc_resolve/diagnostics.rs
Update error codes
[rust.git] / src / librustc_resolve / diagnostics.rs
1 // Copyright 2014 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 #![allow(non_snake_case)]
12
13 // Error messages for EXXXX errors.
14 // Each message should start and end with a new line, and be wrapped to 80 characters.
15 // In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use `:set tw=0` to disable.
16 register_long_diagnostics! {
17
18 E0154: r##"
19 Imports (`use` statements) are not allowed after non-item statements, such as
20 variable declarations and expression statements.
21
22 Here is an example that demonstrates the error:
23
24 ```
25 fn f() {
26     // Variable declaration before import
27     let x = 0;
28     use std::io::Read;
29     ...
30 }
31 ```
32
33 The solution is to declare the imports at the top of the block, function, or
34 file.
35
36 Here is the previous example again, with the correct order:
37
38 ```
39 fn f() {
40     use std::io::Read;
41     let x = 0;
42     ...
43 }
44 ```
45
46 See the Declaration Statements section of the reference for more information
47 about what constitutes an Item declaration and what does not:
48
49 http://doc.rust-lang.org/reference.html#statements
50 "##,
51
52 E0251: r##"
53 Two items of the same name cannot be imported without rebinding one of the
54 items under a new local name.
55
56 An example of this error:
57
58 ```
59 use foo::baz;
60 use bar::*; // error, do `use foo::baz as quux` instead on the previous line
61
62 fn main() {}
63
64 mod foo {
65     pub struct baz;
66 }
67
68 mod bar {
69     pub mod baz {}
70 }
71 ```
72 "##,
73
74 E0252: r##"
75 Two items of the same name cannot be imported without rebinding one of the
76 items under a new local name.
77
78 An example of this error:
79
80 ```
81 use foo::baz;
82 use bar::baz; // error, do `use bar::baz as quux` instead
83
84 fn main() {}
85
86 mod foo {
87     pub struct baz;
88 }
89
90 mod bar {
91     pub mod baz {}
92 }
93 ```
94 "##,
95
96 E0255: r##"
97 You can't import a value whose name is the same as another value defined in the
98 module.
99
100 An example of this error:
101
102 ```
103 use bar::foo; // error, do `use bar::foo as baz` instead
104
105 fn foo() {}
106
107 mod bar {
108      pub fn foo() {}
109 }
110
111 fn main() {}
112 ```
113 "##,
114
115 E0256: r##"
116 You can't import a type or module when the name of the item being imported is
117 the same as another type or submodule defined in the module.
118
119 An example of this error:
120
121 ```
122 use foo::Bar; // error
123
124 type Bar = u32;
125
126 mod foo {
127     pub mod Bar { }
128 }
129
130 fn main() {}
131 ```
132 "##,
133
134 E0259: r##"
135 The name chosen for an external crate conflicts with another external crate that
136 has been imported into the current module.
137
138 Wrong example:
139
140 ```
141 extern crate a;
142 extern crate crate_a as a;
143 ```
144
145 The solution is to choose a different name that doesn't conflict with any
146 external crate imported into the current module.
147
148 Correct example:
149
150 ```
151 extern crate a;
152 extern crate crate_a as other_name;
153 ```
154 "##,
155
156 E0260: r##"
157 The name for an item declaration conflicts with an external crate's name.
158
159 For instance,
160
161 ```
162 extern crate abc;
163
164 struct abc;
165 ```
166
167 There are two possible solutions:
168
169 Solution #1: Rename the item.
170
171 ```
172 extern crate abc;
173
174 struct xyz;
175 ```
176
177 Solution #2: Import the crate with a different name.
178
179 ```
180 extern crate abc as xyz;
181
182 struct abc;
183 ```
184
185 See the Declaration Statements section of the reference for more information
186 about what constitutes an Item declaration and what does not:
187
188 http://doc.rust-lang.org/reference.html#statements
189 "##,
190
191 E0317: r##"
192 User-defined types or type parameters cannot shadow the primitive types.
193 This error indicates you tried to define a type, struct or enum with the same
194 name as an existing primitive type.
195
196 See the Types section of the reference for more information about the primitive
197 types:
198
199 http://doc.rust-lang.org/reference.html#types
200 "##
201
202 }
203
204 register_diagnostics! {
205     E0153, // called no where
206     E0157, // called from no where
207     E0253, // not directly importable
208     E0254, // import conflicts with imported crate in this module
209     E0257,
210     E0258,
211     E0364, // item is private
212     E0365, // item is private
213     E0401, // can't use type parameters from outer function
214     E0402, // cannot use an outer type parameter in this context
215     E0403, // the name `{}` is already used
216     E0404, // is not a trait
217     E0405, // use of undeclared trait name
218     E0406, // undeclared associated type
219     E0407, // method is not a member of trait
220     E0408, // variable from pattern #1 is not bound in pattern #
221     E0409, // variable is bound with different mode in pattern # than in
222            // pattern #1
223     E0410, // variable from pattern is not bound in pattern 1
224     E0411, // use of `Self` outside of an impl or trait
225     E0412, // use of undeclared
226     E0413, // declaration of shadows an enum variant or unit-like struct in
227            // scope
228     E0414, // only irrefutable patterns allowed here
229     E0415, // identifier is bound more than once in this parameter list
230     E0416, // identifier is bound more than once in the same pattern
231     E0417, // static variables cannot be referenced in a pattern, use a
232            // `const` instead
233     E0418, // is not an enum variant, struct or const
234     E0419, // unresolved enum variant, struct or const
235     E0420, // is not an associated const
236     E0421, // unresolved associated const
237     E0422, // does not name a structure
238     E0423, // is a struct variant name, but this expression uses it like a
239            // function name
240     E0424, // `self` is not available in a static method.
241     E0425, // unresolved name
242     E0426, // use of undeclared label
243     E0427, // cannot use `ref` binding mode with ...
244     E0428, // duplicate definition of ...
245     E0429, // `self` imports are only allowed within a { } list
246     E0430, // `self` import can only appear once in the list
247     E0431, // `self` import can only appear in an import list with a non-empty
248            // prefix
249     E0432, // unresolved import
250     E0433, // failed to resolve
251     E0434, // can't capture dynamic environment in a fn item
252     E0435  // attempt to use a non-constant value in a constant
253 }