1 use syntax::{register_diagnostics, register_long_diagnostics};
3 register_long_diagnostics! {
6 Constants can only be initialized by a constant value or, in a future
7 version of Rust, a call to a const function. This error indicates the use
8 of a path (like a::b, or x) denoting something other than one of these
9 allowed items. Erroneous code xample:
12 const FOO: i32 = { let x = 0; x }; // 'x' isn't a constant nor a function!
15 To avoid it, you have to replace the non-constant value:
18 const FOO: i32 = { const X : i32 = 0; X };
20 const FOO2: i32 = { 0 }; // but brackets are useless here
26 You declared a pattern as an argument in a foreign function declaration.
27 Erroneous code example:
31 fn foo((a, b): (u32, u32)); // error: patterns aren't allowed in foreign
32 // function declarations
36 Please replace the pattern argument with a regular one. Example:
45 fn foo(s: SomeStruct); // ok!
53 fn foo(a: (u32, u32)); // ok!
59 Inherent implementations (one that do not implement a trait but provide
60 methods associated with a type) are always safe because they are not
61 implementing an unsafe trait. Removing the `unsafe` keyword from the inherent
62 implementation will resolve this error.
67 // this will cause this error
69 // converting it to this will fix it
75 A negative implementation is one that excludes a type from implementing a
76 particular trait. Not being able to use a trait is always a safe operation,
77 so negative implementations are always safe and never need to be marked as
81 #![feature(optin_builtin_traits)]
85 // unsafe is unnecessary
86 unsafe impl !Clone for Foo { }
91 ```ignore (ignore auto_trait future compatibility warning)
92 #![feature(optin_builtin_traits)]
96 auto trait Enterprise {}
98 impl !Enterprise for Foo { }
101 Please note that negative impls are only allowed for auto traits.
105 This error indicates the use of a loop keyword (`break` or `continue`) inside a
106 closure but outside of any loop. Erroneous code example:
108 ```compile_fail,E0267
109 let w = || { break; }; // error: `break` inside of a closure
112 `break` and `continue` keywords can be used as normal inside closures as long as
113 they are also contained within a loop. To halt the execution of a closure you
114 should instead use a return statement. Example:
128 This error indicates the use of a loop keyword (`break` or `continue`) outside
129 of a loop. Without a loop to break out of or continue in, no sensible action can
130 be taken. Erroneous code example:
132 ```compile_fail,E0268
134 break; // error: `break` outside of loop
138 Please verify that you are using `break` and `continue` only in loops. Example:
150 Trait methods cannot be declared `const` by design. For more information, see
153 [RFC 911]: https://github.com/rust-lang/rfcs/pull/911
157 Auto traits cannot have methods or associated items.
158 For more information see the [opt-in builtin traits RFC][RFC 19].
160 [RFC 19]: https://github.com/rust-lang/rfcs/blob/master/text/0019-opt-in-builtin-traits.md
164 A visibility qualifier was used when it was unnecessary. Erroneous code
167 ```compile_fail,E0449
174 pub impl Bar {} // error: unnecessary visibility qualifier
176 pub impl Foo for Bar { // error: unnecessary visibility qualifier
177 pub fn foo() {} // error: unnecessary visibility qualifier
181 To fix this error, please remove the visibility qualifier when it is not
191 // Directly implemented methods share the visibility of the type itself,
192 // so `pub` is unnecessary here
195 // Trait methods share the visibility of the trait, so `pub` is
196 // unnecessary in either case
205 `break` or `continue` must include a label when used in the condition of a
208 Example of erroneous code:
214 To fix this, add a label specifying which loop is being broken out of:
216 'foo: while break 'foo {}
221 A `break` statement with an argument appeared in a non-`loop` loop.
223 Example of erroneous code:
225 ```compile_fail,E0571
227 # fn satisfied(n: usize) -> bool { n % 23 == 0 }
228 let result = while true {
230 break 2*i; // error: `break` with value from a `while` loop
236 The `break` statement can take an argument (which will be the value of the loop
237 expression if the `break` statement is executed) in `loop` loops, but not
238 `for`, `while`, or `while let` loops.
240 Make sure `break value;` statements only occur in `loop` loops:
244 # fn satisfied(n: usize) -> bool { n % 23 == 0 }
245 let result = loop { // ok!
255 Trait methods currently cannot take patterns as arguments.
257 Example of erroneous code:
259 ```compile_fail,E0642
261 fn foo((x, y): (i32, i32)); // error: patterns aren't allowed
266 You can instead use a single name for the argument:
270 fn foo(x_and_y: (i32, i32)); // ok!
276 A `break` statement without a label appeared inside a labeled block.
278 Example of erroneous code:
280 ```compile_fail,E0695
281 # #![feature(label_break_value)]
289 Make sure to always label the `break`:
292 # #![feature(label_break_value)]
300 Or if you want to `break` the labeled block:
303 # #![feature(label_break_value)]
314 Rust 2015 does not permit the use of `async fn`.
316 Example of erroneous code:
318 ```compile_fail,E0670
322 Switch to the Rust 2018 edition to use `async fn`.
326 register_diagnostics! {
327 E0226, // only a single explicit lifetime bound is permitted
328 E0472, // asm! is unsupported on this target
329 E0561, // patterns aren't allowed in function pointer types
330 E0567, // auto traits can not have generic parameters
331 E0568, // auto traits can not have super traits
332 E0666, // nested `impl Trait` is illegal
333 E0667, // `impl Trait` in projections
334 E0696, // `continue` pointing to a labeled block
335 E0706, // `async fn` in trait