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:
45 ```ignore (compile_fail not working here; see Issue #43707)
46 #[inline()] // error: expected one argument
52 The parenthesized `inline` attribute requires the parameter to be specified:
66 Alternatively, a paren-less version of the attribute may be used to hint the
67 compiler about inlining opportunity:
74 For more information about the inline attribute, read:
75 https://doc.rust-lang.org/reference.html#inline-attributes
79 An unknown argument was given to the `inline` attribute.
81 Erroneous code example:
83 ```ignore (compile_fail not working here; see Issue #43707)
84 #[inline(unknown)] // error: invalid argument
90 The `inline` attribute only supports two arguments:
95 All other arguments given to the `inline` attribute will return this error.
99 #[inline(never)] // ok!
100 pub fn something() {}
105 For more information about the inline attribute, https:
106 read://doc.rust-lang.org/reference.html#inline-attributes
110 The `not` cfg-predicate was malformed.
112 Erroneous code example:
114 ```compile_fail,E0536
115 #[cfg(not())] // error: expected 1 cfg-pattern
116 pub fn something() {}
121 The `not` predicate expects one cfg-pattern. Example:
124 #[cfg(not(target_os = "linux"))] // ok!
125 pub fn something() {}
130 For more information about the cfg attribute, read:
131 https://doc.rust-lang.org/reference.html#conditional-compilation
135 An unknown predicate was used inside the `cfg` attribute.
137 Erroneous code example:
139 ```compile_fail,E0537
140 #[cfg(unknown())] // error: invalid predicate `unknown`
141 pub fn something() {}
146 The `cfg` attribute supports only three kinds of predicates:
155 #[cfg(not(target_os = "linux"))] // ok!
156 pub fn something() {}
161 For more information about the cfg attribute, read:
162 https://doc.rust-lang.org/reference.html#conditional-compilation
166 A unrecognized representation attribute was used.
168 Erroneous code example:
170 ```compile_fail,E0552
171 #[repr(D)] // error: unrecognized representation hint
177 You can use a `repr` attribute to tell the compiler how you want a struct or
178 enum to be laid out in memory.
180 Make sure you're using one of the supported options:
189 For more information about specifying representations, see the ["Alternative
190 Representations" section] of the Rustonomicon.
192 ["Alternative Representations" section]: https://doc.rust-lang.org/nomicon/other-reprs.html
196 Feature attributes are only allowed on the nightly release channel. Stable or
197 beta compilers will not comply.
199 Example of erroneous code (on a stable compiler):
201 ```ignore (depends on release channel)
202 #![feature(non_ascii_idents)] // error: #![feature] may not be used on the
203 // stable release channel
206 If you need the feature, make sure to use a nightly release of the compiler
207 (but be warned that the feature may be removed or altered in the future).
211 A feature attribute named a feature that has been removed.
213 Erroneous code example:
215 ```compile_fail,E0557
216 #![feature(managed_boxes)] // error: feature has been removed
219 Delete the offending feature attribute.
223 The `export_name` attribute was malformed.
225 Erroneous code example:
227 ```compile_fail,E0558
228 #[export_name] // error: export_name attribute has invalid format
229 pub fn something() {}
234 The `export_name` attribute expects a string in order to determine the name of
235 the exported symbol. Example:
238 #[export_name = "some_function"] // ok!
239 pub fn something() {}
246 A literal was used in an attribute that doesn't support literals.
248 Erroneous code example:
250 ```ignore (compile_fail not working here; see Issue #43707)
251 #![feature(attr_literals)]
253 #[inline("always")] // error: unsupported literal
254 pub fn something() {}
257 Literals in attributes are new and largely unsupported. Work to support literals
258 where appropriate is ongoing. Try using an unquoted name instead:
262 pub fn something() {}
267 A file wasn't found for an out-of-line module.
269 Erroneous code example:
271 ```ignore (compile_fail not working here; see Issue #43707)
272 mod file_that_doesnt_exist; // error: file not found for module
277 Please be sure that a file corresponding to the module exists. If you
278 want to use a module named `file_that_doesnt_exist`, you need to have a file
279 named `file_that_doesnt_exist.rs` or `file_that_doesnt_exist/mod.rs` in the
284 A documentation comment that doesn't document anything was found.
286 Erroneous code example:
288 ```compile_fail,E0585
290 // The following doc comment will fail:
291 /// This is a useless doc comment!
295 Documentation comments need to be followed by items, including functions,
296 types, modules, etc. Examples:
299 /// I'm documenting the following struct:
302 /// I'm documenting the following function:
308 An inclusive range was used with no end.
310 Erroneous code example:
312 ```compile_fail,E0586
313 #![feature(inclusive_range_syntax)]
316 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
317 let x = &tmp[1...]; // error: inclusive range was used with no end
321 An inclusive range needs an end in order to *include* it. If you just need a
322 start and no end, use a non-inclusive range (with `..`):
326 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
327 let x = &tmp[1..]; // ok!
331 Or put an end to your inclusive range:
334 #![feature(inclusive_range_syntax)]
337 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
338 let x = &tmp[1...3]; // ok!
345 register_diagnostics! {
346 E0538, // multiple [same] items
347 E0539, // incorrect meta item
348 E0540, // multiple rustc_deprecated attributes
349 E0541, // unknown meta item
350 E0542, // missing 'since'
351 E0543, // missing 'reason'
352 E0544, // multiple stability levels
353 E0545, // incorrect 'issue'
354 E0546, // missing 'feature'
355 E0547, // missing 'issue'
356 E0548, // incorrect stability attribute type
357 E0549, // rustc_deprecated attribute must be paired with either stable or unstable attribute
358 E0550, // multiple deprecated attributes
359 E0551, // incorrect meta item
360 E0555, // malformed feature attribute, expected #![feature(...)]
361 E0556, // malformed feature, expected just one word
362 E0584, // file for module `..` found at both .. and ..
363 E0589, // invalid `repr(align)` attribute