@@ -19,6 +19,51 @@ methods that do not have default implementations), as well as any required
19
19
trait items like associated types or constants.
20
20
"## ,
21
21
22
+ E0049 : r##"
23
+ This error indicates that an attempted implementation of a trait method
24
+ has the wrong number of type parameters.
25
+
26
+ For example, the trait below has a method `foo` with a type parameter `T`,
27
+ but the implementation of `foo` for the type `Bar` is missing this parameter:
28
+
29
+ ```
30
+ trait Foo {
31
+ fn foo<T: Default>(x: T) -> Self;
32
+ }
33
+
34
+ struct Bar;
35
+
36
+ // error: method `foo` has 0 type parameters but its trait declaration has 1
37
+ // type parameter
38
+ impl Foo for Bar {
39
+ fn foo(x: bool) -> Self { Bar }
40
+ }
41
+ ```
42
+ "## ,
43
+
44
+ E0050 : r##"
45
+ This error indicates that an attempted implementation of a trait method
46
+ has the wrong number of function parameters.
47
+
48
+ For example, the trait below has a method `foo` with two function parameters
49
+ (`&self` and `u8`), but the implementation of `foo` for the type `Bar` omits
50
+ the `u8` parameter:
51
+
52
+ ```
53
+ trait Foo {
54
+ fn foo(&self, x: u8) -> bool;
55
+ }
56
+
57
+ struct Bar;
58
+
59
+ // error: method `foo` has 1 parameter but the declaration in trait `Foo::foo`
60
+ // has 2
61
+ impl Foo for Bar {
62
+ fn foo(&self) -> bool { true }
63
+ }
64
+ ```
65
+ "## ,
66
+
22
67
E0054 : r##"
23
68
It is not allowed to cast to a bool. If you are trying to cast a numeric type
24
69
to a bool, you can compare it with zero instead:
@@ -46,6 +91,16 @@ enum variant, one of the fields was not provided. Each field should be specified
46
91
exactly once.
47
92
"## ,
48
93
94
+ E0066 : r##"
95
+ Box placement expressions (like C++'s "placement new") do not support any
96
+ place expression except the exchange heap (i.e. `std::boxed::HEAP`).
97
+ Furthermore, the syntax is changing to use `in` instead of `box`. See [RFC
98
+ 470][rfc470] and [RFC 809][rfc809] for more details.
99
+
100
+ [rfc470]: https://github.com/rust-lang/rfcs/pull/470
101
+ [rfc809]: https://github.com/rust-lang/rfcs/pull/809
102
+ "## ,
103
+
49
104
E0067 : r##"
50
105
The left-hand side of an assignment operator must be an lvalue expression. An
51
106
lvalue expression represents a memory location and includes item paths (ie,
@@ -63,6 +118,22 @@ LinkedList::new() += 1;
63
118
```
64
119
"## ,
65
120
121
+ E0069 : r##"
122
+ This error means that the compiler found a function whose body contains a
123
+ `return;` statement but whose return type is not `()`. For example:
124
+
125
+ ```
126
+ // error
127
+ fn foo() -> u8 {
128
+ return;
129
+ }
130
+ ```
131
+
132
+ When you omit the value from a `return` expression (that is, when you use
133
+ `return;` instead of `return x;`), the value `()` gets returned. So `return;`
134
+ is always incorrect for a function whose return type is not `()`.
135
+ "## ,
136
+
66
137
E0081 : r##"
67
138
Enum discriminants are used to differentiate enum variants stored in memory.
68
139
This error indicates that the same value was used for two or more variants,
@@ -138,6 +209,88 @@ enum Empty {}
138
209
```
139
210
"## ,
140
211
212
+ E0106 : r##"
213
+ This error indicates that a lifetime is missing from a type. If it is an error
214
+ inside a function signature, the problem may be with failing to adhere to the
215
+ lifetime elision rules (see below).
216
+
217
+ Here are some simple examples of where you'll run into this error:
218
+
219
+ ```
220
+ struct Foo { x: &bool } // error
221
+ struct Foo<'a> { x: &'a bool } // correct
222
+
223
+ enum Bar { A(u8), B(&bool), } // error
224
+ enum Bar<'a> { A(u8), B(&'a bool), } // correct
225
+
226
+ type MyStr = &str; // error
227
+ type MyStr<'a> = &'a str; //correct
228
+
229
+ ```
230
+
231
+ Lifetime elision is a special, limited kind of inference for lifetimes in
232
+ function signatures which allows you to leave out lifetimes in certain cases.
233
+ For more background on lifetime elision see [the book][book-le].
234
+
235
+ The lifetime elision rules require that any function signature with an elided
236
+ output lifetime must either have
237
+
238
+ - exactly one input lifetime
239
+ - or, multiple input lifetimes, but the function must also be a method with a
240
+ `&self` or `&mut self` receiver
241
+
242
+ In the first case, the output lifetime is inferred to be the same as the unique
243
+ input lifetime. In the second case, the lifetime is instead inferred to be the
244
+ same as the lifetime on `&self` or `&mut self`.
245
+
246
+ Here are some examples of elision errors:
247
+
248
+ ```
249
+ // error, no input lifetimes
250
+ fn foo() -> &str { ... }
251
+
252
+ // error, `x` and `y` have distinct lifetimes inferred
253
+ fn bar(x: &str, y: &str) -> &str { ... }
254
+
255
+ // error, `y`'s lifetime is inferred to be distinct from `x`'s
256
+ fn baz<'a>(x: &'a str, y: &str) -> &str { ... }
257
+ ```
258
+
259
+ [book-le]: http://doc.rust-lang.org/nightly/book/lifetimes.html#lifetime-elision
260
+ "## ,
261
+
262
+ E0107 : r##"
263
+ This error means that an incorrect number of lifetime parameters were provided
264
+ for a type (like a struct or enum) or trait.
265
+
266
+ Some basic examples include:
267
+
268
+ ```
269
+ struct Foo<'a>(&'a str);
270
+ enum Bar { A, B, C }
271
+
272
+ struct Baz<'a> {
273
+ foo: Foo, // error: expected 1, found 0
274
+ bar: Bar<'a>, // error: expected 0, found 1
275
+ }
276
+ ```
277
+
278
+ Here's an example that is currently an error, but may work in a future version
279
+ of Rust:
280
+
281
+ ```
282
+ struct Foo<'a>(&'a str);
283
+
284
+ trait Quux { }
285
+ impl Quux for Foo { } // error: expected 1, found 0
286
+ ```
287
+
288
+ Lifetime elision in implementation headers was part of the lifetime elision
289
+ RFC. It is, however, [currently unimplemented][iss15872].
290
+
291
+ [iss15872]: https://github.com/rust-lang/rust/issues/15872
292
+ "## ,
293
+
141
294
E0131 : r##"
142
295
It is not possible to define `main` with type parameters, or even with function
143
296
parameters. When `main` is present, it must take no arguments and return `()`.
@@ -152,6 +305,20 @@ fn(isize, *const *const u8) -> isize
152
305
```
153
306
"## ,
154
307
308
+ E0166 : r##"
309
+ This error means that the compiler found a return expression in a function
310
+ marked as diverging. A function diverges if it has `!` in the place of the
311
+ return type in its signature. For example:
312
+
313
+ ```
314
+ fn foo() -> ! { return; } // error
315
+ ```
316
+
317
+ For a function that diverges, every control path in the function must never
318
+ return, for example with a `loop` that never breaks or a call to another
319
+ diverging function (such as `panic!()`).
320
+ "## ,
321
+
155
322
E0184 : r##"
156
323
Explicitly implementing both Drop and Copy for a type is currently disallowed.
157
324
This feature can make some sense in theory, but the current implementation is
@@ -161,6 +328,24 @@ it has been disabled for now.
161
328
[iss20126]: https://github.com/rust-lang/rust/issues/20126
162
329
"## ,
163
330
331
+ E0201 : r##"
332
+ It is an error to define a method--a trait method or an inherent method--more
333
+ than once.
334
+
335
+ For example,
336
+
337
+ ```
338
+ struct Foo(u8);
339
+
340
+ impl Foo {
341
+ fn bar() {}
342
+
343
+ // error: duplicate method
344
+ fn bar(&self) -> bool { self.0 > 5 }
345
+ }
346
+ ```
347
+ "## ,
348
+
164
349
E0204 : r##"
165
350
An attempt to implement the `Copy` trait for a struct failed because one of the
166
351
fields does not implement `Copy`. To fix this, you must implement `Copy` for the
@@ -292,6 +477,13 @@ const B: [u32; foo()] = [];
292
477
use std::{f64, u8};
293
478
const C: [u32; u8::MAX + f64::EPSILON] = [];
294
479
```
480
+ "## ,
481
+
482
+ E0322 : r##"
483
+ The `Sized` trait is a special trait built-in to the compiler for types with a
484
+ constant size known at compile-time. This trait is automatically implemented
485
+ for types as needed by the compiler, and it is currently disallowed to
486
+ explicitly implement it for a type.
295
487
"##
296
488
297
489
}
@@ -313,17 +505,13 @@ register_diagnostics! {
313
505
E0040 , // explicit use of destructor method
314
506
E0044 , // foreign items may not have type parameters
315
507
E0045 , // variadic function must have C calling convention
316
- E0049 ,
317
- E0050 ,
318
508
E0053 ,
319
509
E0055 , // method has an incompatible type for trait
320
510
E0057 , // method has an incompatible type for trait
321
511
E0059 ,
322
512
E0060 ,
323
513
E0061 ,
324
- E0066 ,
325
514
E0068 ,
326
- E0069 ,
327
515
E0070 ,
328
516
E0071 ,
329
517
E0072 ,
@@ -346,8 +534,6 @@ register_diagnostics! {
346
534
E0102 ,
347
535
E0103 ,
348
536
E0104 ,
349
- E0106 ,
350
- E0107 ,
351
537
E0116 ,
352
538
E0117 ,
353
539
E0118 ,
@@ -365,7 +551,6 @@ register_diagnostics! {
365
551
E0159 ,
366
552
E0163 ,
367
553
E0164 ,
368
- E0166 ,
369
554
E0167 ,
370
555
E0168 ,
371
556
E0172 ,
@@ -391,7 +576,6 @@ register_diagnostics! {
391
576
E0198 , // negative implementations are not unsafe
392
577
E0199 , // implementing trait is not unsafe
393
578
E0200 , // trait requires an `unsafe impl` declaration
394
- E0201 , // duplicate method in trait impl
395
579
E0202 , // associated items are not allowed in inherent impls
396
580
E0203 , // type parameter has more than one relaxed default bound,
397
581
// and only one is supported
@@ -422,7 +606,7 @@ register_diagnostics! {
422
606
E0231 , // only named substitution parameters are allowed
423
607
E0232 , // this attribute must have a value
424
608
E0233 ,
425
- E0234 , // `for` loop expression has type which does not implement the `Iterator` trait
609
+ E0234 ,
426
610
E0235 , // structure constructor specifies a structure of type but
427
611
E0236 , // no lang item for range syntax
428
612
E0237 , // no lang item for range syntax
@@ -439,7 +623,6 @@ register_diagnostics! {
439
623
E0319 , // trait impls for defaulted traits allowed just for structs/enums
440
624
E0320 , // recursive overflow during dropck
441
625
E0321 , // extended coherence rules for defaulted traits violated
442
- E0322 , // cannot implement Sized explicitly
443
626
E0323 , // implemented an associated const when another trait item expected
444
627
E0324 , // implemented a method when another trait item expected
445
628
E0325 , // implemented an associated type when another trait item expected
0 commit comments