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.
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.
11 #![allow(non_snake_case)]
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! {
19 In types, the `+` type operator has low precedence, so it is often necessary
28 w: &'a Foo + Copy, // error, use &'a (Foo + Copy)
29 x: &'a Foo + 'a, // error, use &'a (Foo + 'a)
30 y: &'a mut Foo + 'a, // error, use &'a mut (Foo + 'a)
31 z: fn() -> Foo + 'a, // error, use fn() -> (Foo + 'a)
35 More details can be found in [RFC 438].
37 [RFC 438]: https://github.com/rust-lang/rfcs/pull/438
41 The `inline` attribute was malformed.
43 Erroneous code example:
46 #[inline()] // error: expected one argument
52 The parenthesized `inline` attribute requires the parameter to be specified:
64 Alternatively, a paren-less version of the attribute may be used to hint the
65 compiler about inlining opportunity:
72 For more information about the inline attribute, read:
73 https://doc.rust-lang.org/reference.html#inline-attributes
77 An unknown argument was given to the `inline` attribute.
79 Erroneous code example:
82 #[inline(unknown)] // error: invalid argument
88 The `inline` attribute only supports two arguments:
93 All other arguments given to the `inline` attribute will return this error.
97 #[inline(never)] // ok!
103 For more information about the inline attribute, https:
104 read://doc.rust-lang.org/reference.html#inline-attributes
108 The `not` cfg-predicate was malformed.
110 Erroneous code example:
112 ```compile_fail,E0536
113 #[cfg(not())] // error: expected 1 cfg-pattern
114 pub fn something() {}
119 The `not` predicate expects one cfg-pattern. Example:
122 #[cfg(not(target_os = "linux"))] // ok!
123 pub fn something() {}
128 For more information about the cfg attribute, read:
129 https://doc.rust-lang.org/reference.html#conditional-compilation
133 An unknown predicate was used inside the `cfg` attribute.
135 Erroneous code example:
137 ```compile_fail,E0537
138 #[cfg(unknown())] // error: invalid predicate `unknown`
139 pub fn something() {}
144 The `cfg` attribute supports only three kinds of predicates:
153 #[cfg(not(target_os = "linux"))] // ok!
154 pub fn something() {}
159 For more information about the cfg attribute, read:
160 https://doc.rust-lang.org/reference.html#conditional-compilation
164 The `export_name` attribute was malformed.
166 Erroneous code example:
168 ```compile_fail,E0558
169 #[export_name] // error: export_name attribute has invalid format
170 pub fn something() {}
175 The `export_name` attribute expects a string in order to determine the name of
176 the exported symbol. Example:
179 #[export_name = "some_function"] // ok!
180 pub fn something() {}
187 A literal was used in an attribute that doesn't support literals.
189 Erroneous code example:
191 ```compile_fail,E0565
192 #[inline("always")] // error: unsupported literal
193 pub fn something() {}
196 Literals in attributes are new and largely unsupported. Work to support literals
197 where appropriate is ongoing. Try using an unquoted name instead:
201 pub fn something() {}
206 A file wasn't found for an out-of-line module.
208 Erroneous code example:
210 ```compile_fail,E0583
211 mod file_that_doesnt_exist; // error: file not found for module
216 Please be sure that a file corresponding to the module exists. If you
217 want to use a module named `file_that_doesnt_exist`, you need to have a file
218 named `file_that_doesnt_exist.rs` or `file_that_doesnt_exist/mod.rs` in the
223 A documentation comment that doesn't document anything was found.
225 Erroneous code example:
227 ```compile_fail,E0585
229 // The following doc comment will fail:
230 /// This is a useless doc comment!
234 Documentation comments need to be followed by items, including functions,
235 types, modules, etc. Examples:
238 /// I'm documenting the following struct:
241 /// I'm documenting the following function:
247 An inclusive range was used with no end.
249 Erroneous code example:
251 ```compile_fail,E0586
252 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
253 let x = &tmp[1...]; // error: inclusive range was used with no end
256 An inclusive range needs an end in order to *include* it. If you just need a
257 start and no end, use a non-inclusive range (with `..`):
260 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
261 let x = &tmp[1..]; // ok!
264 Or put an end to your inclusive range:
267 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
268 let x = &tmp[1...3]; // ok!
274 register_diagnostics! {
275 E0538, // multiple [same] items
276 E0539, // incorrect meta item
277 E0540, // multiple rustc_deprecated attributes
278 E0541, // unknown meta item
279 E0542, // missing 'since'
280 E0543, // missing 'reason'
281 E0544, // multiple stability levels
282 E0545, // incorrect 'issue'
283 E0546, // missing 'feature'
284 E0547, // missing 'issue'
285 E0548, // incorrect stability attribute type
286 E0549, // rustc_deprecated attribute must be paired with either stable or unstable attribute
287 E0550, // multiple deprecated attributes
288 E0551, // incorrect meta item
289 E0552, // unrecognized representation hint
290 E0554, // #[feature] may not be used on the [] release channel
291 E0555, // malformed feature attribute, expected #![feature(...)]
292 E0556, // malformed feature, expected just one word
293 E0557, // feature has been removed
294 E0584, // file for module `..` found at both .. and ..
295 E0589, // invalid `repr(align)` attribute