1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
#![allow(non_snake_case)]
register_long_diagnostics! {
E0178: r##"
In types, the `+` type operator has low precedence, so it is often necessary
to use parentheses.
For example:
```compile_fail,E0178
trait Foo {}
struct Bar<'a> {
w: &'a Foo + Copy, // error, use &'a (Foo + Copy)
x: &'a Foo + 'a, // error, use &'a (Foo + 'a)
y: &'a mut Foo + 'a, // error, use &'a mut (Foo + 'a)
z: fn() -> Foo + 'a, // error, use fn() -> (Foo + 'a)
}
```
More details can be found in [RFC 438].
[RFC 438]: https://github.com/rust-lang/rfcs/pull/438
"##,
E0536: r##"
The `not` cfg-predicate was malformed.
Erroneous code example:
```compile_fail,E0536
#[cfg(not())] // error: expected 1 cfg-pattern
pub fn something() {}
pub fn main() {}
```
The `not` predicate expects one cfg-pattern. Example:
```
#[cfg(not(target_os = "linux"))] // ok!
pub fn something() {}
pub fn main() {}
```
For more information about the cfg attribute, read:
https://doc.rust-lang.org/reference.html#conditional-compilation
"##,
E0537: r##"
An unknown predicate was used inside the `cfg` attribute.
Erroneous code example:
```compile_fail,E0537
#[cfg(unknown())] // error: invalid predicate `unknown`
pub fn something() {}
pub fn main() {}
```
The `cfg` attribute supports only three kinds of predicates:
* any
* all
* not
Example:
```
#[cfg(not(target_os = "linux"))] // ok!
pub fn something() {}
pub fn main() {}
```
For more information about the cfg attribute, read:
https://doc.rust-lang.org/reference.html#conditional-compilation
"##,
E0552: r##"
A unrecognized representation attribute was used.
Erroneous code example:
```compile_fail,E0552
#[repr(D)] // error: unrecognized representation hint
struct MyStruct {
my_field: usize
}
```
You can use a `repr` attribute to tell the compiler how you want a struct or
enum to be laid out in memory.
Make sure you're using one of the supported options:
```
#[repr(C)] // ok!
struct MyStruct {
my_field: usize
}
```
For more information about specifying representations, see the ["Alternative
Representations" section] of the Rustonomicon.
["Alternative Representations" section]: https://doc.rust-lang.org/nomicon/other-reprs.html
"##,
E0554: r##"
Feature attributes are only allowed on the nightly release channel. Stable or
beta compilers will not comply.
Example of erroneous code (on a stable compiler):
```ignore (depends on release channel)
#![feature(non_ascii_idents)] // error: #![feature] may not be used on the
// stable release channel
```
If you need the feature, make sure to use a nightly release of the compiler
(but be warned that the feature may be removed or altered in the future).
"##,
E0557: r##"
A feature attribute named a feature that has been removed.
Erroneous code example:
```compile_fail,E0557
#![feature(managed_boxes)] // error: feature has been removed
```
Delete the offending feature attribute.
"##,
E0565: r##"
A literal was used in an attribute that doesn't support literals.
Erroneous code example:
```ignore (compile_fail not working here; see Issue #43707)
#![feature(attr_literals)]
#[inline("always")] // error: unsupported literal
pub fn something() {}
```
Literals in attributes are new and largely unsupported. Work to support literals
where appropriate is ongoing. Try using an unquoted name instead:
```
#[inline(always)]
pub fn something() {}
```
"##,
E0583: r##"
A file wasn't found for an out-of-line module.
Erroneous code example:
```ignore (compile_fail not working here; see Issue #43707)
mod file_that_doesnt_exist; // error: file not found for module
fn main() {}
```
Please be sure that a file corresponding to the module exists. If you
want to use a module named `file_that_doesnt_exist`, you need to have a file
named `file_that_doesnt_exist.rs` or `file_that_doesnt_exist/mod.rs` in the
same directory.
"##,
E0585: r##"
A documentation comment that doesn't document anything was found.
Erroneous code example:
```compile_fail,E0585
fn main() {
// The following doc comment will fail:
/// This is a useless doc comment!
}
```
Documentation comments need to be followed by items, including functions,
types, modules, etc. Examples:
```
/// I'm documenting the following struct:
struct Foo;
/// I'm documenting the following function:
fn foo() {}
```
"##,
E0586: r##"
An inclusive range was used with no end.
Erroneous code example:
```compile_fail,E0586
fn main() {
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
let x = &tmp[1..=]; // error: inclusive range was used with no end
}
```
An inclusive range needs an end in order to *include* it. If you just need a
start and no end, use a non-inclusive range (with `..`):
```
fn main() {
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
let x = &tmp[1..]; // ok!
}
```
Or put an end to your inclusive range:
```
fn main() {
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
let x = &tmp[1..=3]; // ok!
}
```
"##,
E0658: r##"
An unstable feature was used.
Erroneous code example:
```compile_fail,E658
let x = ::std::u128::MAX; // error: use of unstable library feature 'i128'
```
If you're using a stable or a beta version of rustc, you won't be able to use
any unstable features. In order to do so, please switch to a nightly version of
rustc (by using rustup).
If you're using a nightly version of rustc, just add the corresponding feature
to be able to use it:
```
#![feature(i128)]
fn main() {
let x = ::std::u128::MAX; // ok!
}
```
"##,
E0633: r##"
The `unwind` attribute was malformed.
Erroneous code example:
```ignore (compile_fail not working here; see Issue #43707)
#[unwind()] // error: expected one argument
pub extern fn something() {}
fn main() {}
```
The `#[unwind]` attribute should be used as follows:
- `#[unwind(aborts)]` -- specifies that if a non-Rust ABI function
should abort the process if it attempts to unwind. This is the safer
and preferred option.
- `#[unwind(allowed)]` -- specifies that a non-Rust ABI function
should be allowed to unwind. This can easily result in Undefined
Behavior (UB), so be careful.
NB. The default behavior here is "allowed", but this is unspecified
and likely to change in the future.
"##,
}
register_diagnostics! {
E0538,
E0539,
E0540,
E0541,
E0542,
E0543,
E0544,
E0545,
E0546,
E0547,
E0548,
E0549,
E0550,
E0551,
E0553,
E0555,
E0556,
E0584,
E0589,
E0629,
E0630,
}