1 #![allow(non_snake_case)]
3 use syntax::{register_diagnostic, register_diagnostics, register_long_diagnostics};
5 register_long_diagnostics! {
8 Constants can only be initialized by a constant value or, in a future
9 version of Rust, a call to a const function. This error indicates the use
10 of a path (like a::b, or x) denoting something other than one of these
11 allowed items. Erroneous code xample:
14 const FOO: i32 = { let x = 0; x }; // 'x' isn't a constant nor a function!
17 To avoid it, you have to replace the non-constant value:
20 const FOO: i32 = { const X : i32 = 0; X };
22 const FOO2: i32 = { 0 }; // but brackets are useless here
28 You declared a pattern as an argument in a foreign function declaration.
29 Erroneous code example:
33 fn foo((a, b): (u32, u32)); // error: patterns aren't allowed in foreign
34 // function declarations
38 Please replace the pattern argument with a regular one. Example:
47 fn foo(s: SomeStruct); // ok!
55 fn foo(a: (u32, u32)); // ok!
61 Inherent implementations (one that do not implement a trait but provide
62 methods associated with a type) are always safe because they are not
63 implementing an unsafe trait. Removing the `unsafe` keyword from the inherent
64 implementation will resolve this error.
69 // this will cause this error
71 // converting it to this will fix it
77 A negative implementation is one that excludes a type from implementing a
78 particular trait. Not being able to use a trait is always a safe operation,
79 so negative implementations are always safe and never need to be marked as
83 #![feature(optin_builtin_traits)]
87 // unsafe is unnecessary
88 unsafe impl !Clone for Foo { }
93 ```ignore (ignore auto_trait future compatibility warning)
94 #![feature(optin_builtin_traits)]
98 auto trait Enterprise {}
100 impl !Enterprise for Foo { }
103 Please note that negative impls are only allowed for auto traits.
107 This error indicates the use of a loop keyword (`break` or `continue`) inside a
108 closure but outside of any loop. Erroneous code example:
110 ```compile_fail,E0267
111 let w = || { break; }; // error: `break` inside of a closure
114 `break` and `continue` keywords can be used as normal inside closures as long as
115 they are also contained within a loop. To halt the execution of a closure you
116 should instead use a return statement. Example:
130 This error indicates the use of a loop keyword (`break` or `continue`) outside
131 of a loop. Without a loop to break out of or continue in, no sensible action can
132 be taken. Erroneous code example:
134 ```compile_fail,E0268
136 break; // error: `break` outside of loop
140 Please verify that you are using `break` and `continue` only in loops. Example:
152 Trait methods cannot be declared `const` by design. For more information, see
155 [RFC 911]: https://github.com/rust-lang/rfcs/pull/911
159 Auto traits cannot have methods or associated items.
160 For more information see the [opt-in builtin traits RFC][RFC 19].
162 [RFC 19]: https://github.com/rust-lang/rfcs/blob/master/text/0019-opt-in-builtin-traits.md
166 A visibility qualifier was used when it was unnecessary. Erroneous code
169 ```compile_fail,E0449
176 pub impl Bar {} // error: unnecessary visibility qualifier
178 pub impl Foo for Bar { // error: unnecessary visibility qualifier
179 pub fn foo() {} // error: unnecessary visibility qualifier
183 To fix this error, please remove the visibility qualifier when it is not
193 // Directly implemented methods share the visibility of the type itself,
194 // so `pub` is unnecessary here
197 // Trait methods share the visibility of the trait, so `pub` is
198 // unnecessary in either case
207 `break` or `continue` must include a label when used in the condition of a
210 Example of erroneous code:
216 To fix this, add a label specifying which loop is being broken out of:
218 'foo: while break 'foo {}
223 A `break` statement with an argument appeared in a non-`loop` loop.
225 Example of erroneous code:
227 ```compile_fail,E0571
229 # fn satisfied(n: usize) -> bool { n % 23 == 0 }
230 let result = while true {
232 break 2*i; // error: `break` with value from a `while` loop
238 The `break` statement can take an argument (which will be the value of the loop
239 expression if the `break` statement is executed) in `loop` loops, but not
240 `for`, `while`, or `while let` loops.
242 Make sure `break value;` statements only occur in `loop` loops:
246 # fn satisfied(n: usize) -> bool { n % 23 == 0 }
247 let result = loop { // ok!
257 Trait methods currently cannot take patterns as arguments.
259 Example of erroneous code:
261 ```compile_fail,E0642
263 fn foo((x, y): (i32, i32)); // error: patterns aren't allowed
268 You can instead use a single name for the argument:
272 fn foo(x_and_y: (i32, i32)); // ok!
278 A `break` statement without a label appeared inside a labeled block.
280 Example of erroneous code:
282 ```compile_fail,E0695
283 # #![feature(label_break_value)]
291 Make sure to always label the `break`:
294 # #![feature(label_break_value)]
302 Or if you want to `break` the labeled block:
305 # #![feature(label_break_value)]
316 Rust 2015 does not permit the use of `async fn`.
318 Example of erroneous code:
320 ```compile_fail,E0670
324 Switch to the Rust 2018 edition to use `async fn`.
328 register_diagnostics! {
329 E0226, // only a single explicit lifetime bound is permitted
330 E0472, // asm! is unsupported on this target
331 E0561, // patterns aren't allowed in function pointer types
332 E0567, // auto traits can not have generic parameters
333 E0568, // auto traits can not have super traits
334 E0666, // nested `impl Trait` is illegal
335 E0667, // `impl Trait` in projections
336 E0696, // `continue` pointing to a labeled block
337 E0706, // `async fn` in trait