1 // Error messages for EXXXX errors.
2 // Each message should start and end with a new line, and be wrapped to 80
3 // characters. In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use
4 // `:set tw=0` to disable.
5 register_diagnostics! {
8 The `not` cfg-predicate was malformed.
10 Erroneous code example:
13 #[cfg(not())] // error: expected 1 cfg-pattern
19 The `not` predicate expects one cfg-pattern. Example:
22 #[cfg(not(target_os = "linux"))] // ok!
28 For more information about the cfg attribute, read:
29 https://doc.rust-lang.org/reference.html#conditional-compilation
33 An unknown predicate was used inside the `cfg` attribute.
35 Erroneous code example:
38 #[cfg(unknown())] // error: invalid predicate `unknown`
44 The `cfg` attribute supports only three kinds of predicates:
53 #[cfg(not(target_os = "linux"))] // ok!
59 For more information about the cfg attribute, read:
60 https://doc.rust-lang.org/reference.html#conditional-compilation
64 Attribute contains same meta item more than once.
66 Erroneous code example:
71 note="First deprecation note.",
72 note="Second deprecation note." // error: multiple same meta item
74 fn deprecated_function() {}
77 Meta items are the key-value pairs inside of an attribute. Each key may only be
78 used once in each attribute.
80 To fix the problem, remove all but one of the meta items with the same key.
87 note="First deprecation note."
89 fn deprecated_function() {}
94 An unknown meta item was used.
96 Erroneous code example:
101 // error: unknown meta item
102 reason="Example invalid meta item. Should be 'note'")
104 fn deprecated_function() {}
107 Meta items are the key-value pairs inside of an attribute. The keys provided
108 must be one of the valid keys for the specified attribute.
110 To fix the problem, either remove the unknown meta item, or rename it if you
111 provided the wrong name.
113 In the erroneous code example above, the wrong name was provided, so changing
114 to a correct one it will fix the error. Example:
119 note="This is a valid meta item for the deprecated attribute."
121 fn deprecated_function() {}
126 More than one `deprecated` attribute has been put on an item.
128 Erroneous code example:
130 ```compile_fail,E0550
131 #[deprecated(note = "because why not?")]
132 #[deprecated(note = "right?")] // error!
136 The `deprecated` attribute can only be present **once** on an item.
139 #[deprecated(note = "because why not, right?")]
140 fn the_banished() {} // ok!
145 An invalid meta-item was used inside an attribute.
147 Erroneous code example:
149 ```compile_fail,E0551
150 #[deprecated(note)] // error!
151 fn i_am_deprecated() {}
154 Meta items are the key-value pairs inside of an attribute. To fix this issue,
155 you need to give a value to the `note` key. Example:
158 #[deprecated(note = "because")] // ok!
159 fn i_am_deprecated() {}
164 A unrecognized representation attribute was used.
166 Erroneous code example:
168 ```compile_fail,E0552
169 #[repr(D)] // error: unrecognized representation hint
175 You can use a `repr` attribute to tell the compiler how you want a struct or
176 enum to be laid out in memory.
178 Make sure you're using one of the supported options:
187 For more information about specifying representations, see the ["Alternative
188 Representations" section] of the Rustonomicon.
190 ["Alternative Representations" section]: https://doc.rust-lang.org/nomicon/other-reprs.html
194 Feature attributes are only allowed on the nightly release channel. Stable or
195 beta compilers will not comply.
197 Example of erroneous code (on a stable compiler):
199 ```ignore (depends on release channel)
200 #![feature(non_ascii_idents)] // error: `#![feature]` may not be used on the
201 // stable release channel
204 If you need the feature, make sure to use a nightly release of the compiler
205 (but be warned that the feature may be removed or altered in the future).
209 The `feature` attribute was badly formed.
211 Erroneous code example:
213 ```compile_fail,E0556
214 #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)] // error!
215 #![feature] // error!
216 #![feature = "foo"] // error!
219 The `feature` attribute only accept a "feature flag" and can only be used on
222 ```ignore (only works in nightly)
228 A feature attribute named a feature that has been removed.
230 Erroneous code example:
232 ```compile_fail,E0557
233 #![feature(managed_boxes)] // error: feature has been removed
236 Delete the offending feature attribute.
240 A literal was used in a built-in attribute that doesn't support literals.
242 Erroneous code example:
244 ```ignore (compile_fail not working here; see Issue #43707)
245 #[inline("always")] // error: unsupported literal
246 pub fn something() {}
249 Literals in attributes are new and largely unsupported in built-in attributes.
250 Work to support literals where appropriate is ongoing. Try using an unquoted
255 pub fn something() {}
260 The value of `N` that was specified for `repr(align(N))` was not a power
261 of two, or was greater than 2^29.
263 ```compile_fail,E0589
264 #[repr(align(15))] // error: invalid `repr(align)` attribute: not a power of two
272 An unstable feature was used.
274 Erroneous code example:
277 #[repr(u128)] // error: use of unstable library feature 'repr128'
283 If you're using a stable or a beta version of rustc, you won't be able to use
284 any unstable features. In order to do so, please switch to a nightly version of
285 rustc (by using rustup).
287 If you're using a nightly version of rustc, just add the corresponding feature
288 to be able to use it:
301 The `unwind` attribute was malformed.
303 Erroneous code example:
305 ```ignore (compile_fail not working here; see Issue #43707)
306 #[unwind()] // error: expected one argument
307 pub extern fn something() {}
312 The `#[unwind]` attribute should be used as follows:
314 - `#[unwind(aborts)]` -- specifies that if a non-Rust ABI function
315 should abort the process if it attempts to unwind. This is the safer
316 and preferred option.
318 - `#[unwind(allowed)]` -- specifies that a non-Rust ABI function
319 should be allowed to unwind. This can easily result in Undefined
320 Behavior (UB), so be careful.
322 NB. The default behavior here is "allowed", but this is unspecified
323 and likely to change in the future.
328 A `#![feature]` attribute was declared for a feature that is stable in
329 the current edition, but not in all editions.
331 Erroneous code example:
333 ```ignore (limited to a warning during 2018 edition development)
334 #![feature(rust_2018_preview)]
335 #![feature(test_2018_feature)] // error: the feature
336 // `test_2018_feature` is
337 // included in the Rust 2018 edition
342 A feature attribute named a feature that was disallowed in the compiler
345 Erroneous code example:
347 ```ignore (can't specify compiler flags from doctests)
348 #![feature(never_type)] // error: the feature `never_type` is not in
349 // the list of allowed features
352 Delete the offending feature attribute, or add it to the list of allowed
353 features in the `-Z allow_features` flag.
358 E0539, // incorrect meta item
359 E0540, // multiple rustc_deprecated attributes
360 E0542, // missing 'since'
361 E0543, // missing 'reason'
362 E0544, // multiple stability levels
363 E0545, // incorrect 'issue'
364 E0546, // missing 'feature'
365 E0547, // missing 'issue'
366 // E0548, // replaced with a generic attribute input check
367 // rustc_deprecated attribute must be paired with either stable or unstable
370 E0553, // multiple rustc_const_unstable attributes
371 // E0555, // replaced with a generic attribute input check
372 E0629, // missing 'feature' (rustc_const_unstable)
373 // rustc_const_unstable attribute must be paired with stable/unstable
376 E0693, // incorrect `repr(align)` attribute format
377 // E0694, // an unknown tool name found in scoped attributes
378 E0717, // rustc_promotable without stability attribute