1 #![allow(non_snake_case)]
3 // Error messages for EXXXX errors.
4 // Each message should start and end with a new line, and be wrapped to 80 characters.
5 // In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use `:set tw=0` to disable.
6 register_long_diagnostics! {
9 In types, the `+` type operator has low precedence, so it is often necessary
18 w: &'a Foo + Copy, // error, use &'a (Foo + Copy)
19 x: &'a Foo + 'a, // error, use &'a (Foo + 'a)
20 y: &'a mut Foo + 'a, // error, use &'a mut (Foo + 'a)
21 z: fn() -> Foo + 'a, // error, use fn() -> (Foo + 'a)
25 More details can be found in [RFC 438].
27 [RFC 438]: https://github.com/rust-lang/rfcs/pull/438
31 The `not` cfg-predicate was malformed.
33 Erroneous code example:
36 #[cfg(not())] // error: expected 1 cfg-pattern
42 The `not` predicate expects one cfg-pattern. Example:
45 #[cfg(not(target_os = "linux"))] // ok!
51 For more information about the cfg attribute, read:
52 https://doc.rust-lang.org/reference.html#conditional-compilation
56 An unknown predicate was used inside the `cfg` attribute.
58 Erroneous code example:
61 #[cfg(unknown())] // error: invalid predicate `unknown`
67 The `cfg` attribute supports only three kinds of predicates:
76 #[cfg(not(target_os = "linux"))] // ok!
82 For more information about the cfg attribute, read:
83 https://doc.rust-lang.org/reference.html#conditional-compilation
87 Attribute contains same meta item more than once.
89 Erroneous code example:
94 note="First deprecation note.",
95 note="Second deprecation note." // error: multiple same meta item
97 fn deprecated_function() {}
100 Meta items are the key-value pairs inside of an attribute. Each key may only be
101 used once in each attribute.
103 To fix the problem, remove all but one of the meta items with the same key.
110 note="First deprecation note."
112 fn deprecated_function() {}
117 An unknown meta item was used.
119 Erroneous code example:
121 ```compile_fail,E0541
124 // error: unknown meta item
125 reason="Example invalid meta item. Should be 'note'")
127 fn deprecated_function() {}
130 Meta items are the key-value pairs inside of an attribute. The keys provided
131 must be one of the valid keys for the specified attribute.
133 To fix the problem, either remove the unknown meta item, or rename it if you
134 provided the wrong name.
136 In the erroneous code example above, the wrong name was provided, so changing
137 to a correct one it will fix the error. Example:
142 note="This is a valid meta item for the deprecated attribute."
144 fn deprecated_function() {}
149 A unrecognized representation attribute was used.
151 Erroneous code example:
153 ```compile_fail,E0552
154 #[repr(D)] // error: unrecognized representation hint
160 You can use a `repr` attribute to tell the compiler how you want a struct or
161 enum to be laid out in memory.
163 Make sure you're using one of the supported options:
172 For more information about specifying representations, see the ["Alternative
173 Representations" section] of the Rustonomicon.
175 ["Alternative Representations" section]: https://doc.rust-lang.org/nomicon/other-reprs.html
179 Feature attributes are only allowed on the nightly release channel. Stable or
180 beta compilers will not comply.
182 Example of erroneous code (on a stable compiler):
184 ```ignore (depends on release channel)
185 #![feature(non_ascii_idents)] // error: #![feature] may not be used on the
186 // stable release channel
189 If you need the feature, make sure to use a nightly release of the compiler
190 (but be warned that the feature may be removed or altered in the future).
194 A feature attribute named a feature that has been removed.
196 Erroneous code example:
198 ```compile_fail,E0557
199 #![feature(managed_boxes)] // error: feature has been removed
202 Delete the offending feature attribute.
206 A literal was used in a built-in attribute that doesn't support literals.
208 Erroneous code example:
210 ```ignore (compile_fail not working here; see Issue #43707)
211 #[inline("always")] // error: unsupported literal
212 pub fn something() {}
215 Literals in attributes are new and largely unsupported in built-in attributes.
216 Work to support literals where appropriate is ongoing. Try using an unquoted
221 pub fn something() {}
226 A file wasn't found for an out-of-line module.
228 Erroneous code example:
230 ```ignore (compile_fail not working here; see Issue #43707)
231 mod file_that_doesnt_exist; // error: file not found for module
236 Please be sure that a file corresponding to the module exists. If you
237 want to use a module named `file_that_doesnt_exist`, you need to have a file
238 named `file_that_doesnt_exist.rs` or `file_that_doesnt_exist/mod.rs` in the
243 A documentation comment that doesn't document anything was found.
245 Erroneous code example:
247 ```compile_fail,E0585
249 // The following doc comment will fail:
250 /// This is a useless doc comment!
254 Documentation comments need to be followed by items, including functions,
255 types, modules, etc. Examples:
258 /// I'm documenting the following struct:
261 /// I'm documenting the following function:
267 An inclusive range was used with no end.
269 Erroneous code example:
271 ```compile_fail,E0586
273 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
274 let x = &tmp[1..=]; // error: inclusive range was used with no end
278 An inclusive range needs an end in order to *include* it. If you just need a
279 start and no end, use a non-inclusive range (with `..`):
283 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
284 let x = &tmp[1..]; // ok!
288 Or put an end to your inclusive range:
292 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
293 let x = &tmp[1..=3]; // ok!
299 The value of `N` that was specified for `repr(align(N))` was not a power
300 of two, or was greater than 2^29.
302 ```compile_fail,E0589
303 #[repr(align(15))] // error: invalid `repr(align)` attribute: not a power of two
311 An unstable feature was used.
313 Erroneous code example:
316 #[repr(u128)] // error: use of unstable library feature 'repr128'
322 If you're using a stable or a beta version of rustc, you won't be able to use
323 any unstable features. In order to do so, please switch to a nightly version of
324 rustc (by using rustup).
326 If you're using a nightly version of rustc, just add the corresponding feature
327 to be able to use it:
340 The `unwind` attribute was malformed.
342 Erroneous code example:
344 ```ignore (compile_fail not working here; see Issue #43707)
345 #[unwind()] // error: expected one argument
346 pub extern fn something() {}
351 The `#[unwind]` attribute should be used as follows:
353 - `#[unwind(aborts)]` -- specifies that if a non-Rust ABI function
354 should abort the process if it attempts to unwind. This is the safer
355 and preferred option.
357 - `#[unwind(allowed)]` -- specifies that a non-Rust ABI function
358 should be allowed to unwind. This can easily result in Undefined
359 Behavior (UB), so be careful.
361 NB. The default behavior here is "allowed", but this is unspecified
362 and likely to change in the future.
367 A `#![feature]` attribute was declared for a feature that is stable in
368 the current edition, but not in all editions.
370 Erroneous code example:
372 ```ignore (limited to a warning during 2018 edition development)
373 #![feature(rust_2018_preview)]
374 #![feature(test_2018_feature)] // error: the feature
375 // `test_2018_feature` is
376 // included in the Rust 2018 edition
383 register_diagnostics! {
384 E0539, // incorrect meta item
385 E0540, // multiple rustc_deprecated attributes
386 E0542, // missing 'since'
387 E0543, // missing 'reason'
388 E0544, // multiple stability levels
389 E0545, // incorrect 'issue'
390 E0546, // missing 'feature'
391 E0547, // missing 'issue'
392 // E0548, // replaced with a generic attribute input check
393 E0549, // rustc_deprecated attribute must be paired with either stable or unstable attribute
394 E0550, // multiple deprecated attributes
395 E0551, // incorrect meta item
396 E0553, // multiple rustc_const_unstable attributes
397 // E0555, // replaced with a generic attribute input check
398 E0556, // malformed feature, expected just one word
399 E0584, // file for module `..` found at both .. and ..
400 E0629, // missing 'feature' (rustc_const_unstable)
401 E0630, // rustc_const_unstable attribute must be paired with stable/unstable attribute
402 E0693, // incorrect `repr(align)` attribute format
403 E0694, // an unknown tool name found in scoped attributes
404 E0703, // invalid ABI
405 E0704, // incorrect visibility restriction
406 E0717, // rustc_promotable without stability attribute