@@ -64,6 +64,43 @@ impl Foo for Bar {
6464```
6565"## ,
6666
67+ E0053 : r##"
68+ For any given method of a trait, the mutabilities of the parameters must match
69+ between the trait definition and the implementation.
70+
71+ Here's an example where the mutability of the `self` parameter is wrong:
72+
73+ ```
74+ trait Foo { fn foo(&self); }
75+
76+ struct Bar;
77+
78+ impl Foo for Bar {
79+ // error, the signature should be `fn foo(&self)` instead
80+ fn foo(&mut self) { }
81+ }
82+
83+ fn main() {}
84+ ```
85+
86+ Here's another example, this time for a non-`self` parameter:
87+
88+ ```
89+ trait Foo { fn foo(x: &mut bool) -> bool; }
90+
91+ struct Bar;
92+
93+ impl Foo for Bar {
94+ // error, the type of `x` should be `&mut bool` instead
95+ fn foo(x: &bool) -> bool { *x }
96+ }
97+
98+ fn main() {}
99+ ```
100+
101+
102+ "## ,
103+
67104E0054 : r##"
68105It is not allowed to cast to a bool. If you are trying to cast a numeric type
69106to a bool, you can compare it with zero instead:
@@ -91,6 +128,16 @@ enum variant, one of the fields was not provided. Each field should be specified
91128exactly once.
92129"## ,
93130
131+ E0066 : r##"
132+ Box placement expressions (like C++'s "placement new") do not yet support any
133+ place expression except the exchange heap (i.e. `std::boxed::HEAP`).
134+ Furthermore, the syntax is changing to use `in` instead of `box`. See [RFC 470]
135+ and [RFC 809] for more details.
136+
137+ [RFC 470]: https://github.com/rust-lang/rfcs/pull/470
138+ [RFC 809]: https://github.com/rust-lang/rfcs/pull/809
139+ "## ,
140+
94141E0067 : r##"
95142The left-hand side of an assignment operator must be an lvalue expression. An
96143lvalue expression represents a memory location and includes item paths (ie,
@@ -108,6 +155,21 @@ LinkedList::new() += 1;
108155```
109156"## ,
110157
158+ E0069 : r##"
159+ The compiler found a function whose body contains a `return;` statement but
160+ whose return type is not `()`. An example of this is:
161+
162+ ```
163+ // error
164+ fn foo() -> u8 {
165+ return;
166+ }
167+ ```
168+
169+ Since `return;` is just like `return ();`, there is a mismatch between the
170+ function's return type and the value being returned.
171+ "## ,
172+
111173E0081 : r##"
112174Enum discriminants are used to differentiate enum variants stored in memory.
113175This error indicates that the same value was used for two or more variants,
@@ -458,6 +520,48 @@ The `Sized` trait is a special trait built-in to the compiler for types with a
458520constant size known at compile-time. This trait is automatically implemented
459521for types as needed by the compiler, and it is currently disallowed to
460522explicitly implement it for a type.
523+ "## ,
524+
525+ E0368 : r##"
526+ This error indicates that a binary assignment operator like `+=` or `^=` was
527+ applied to the wrong types.
528+
529+ A couple examples of this are as follows:
530+
531+ ```
532+ let mut x: u16 = 5;
533+ x ^= true; // error, `^=` cannot be applied to types `u16` and `bool`
534+ x += (); // error, `+=` cannot be applied to types `u16` and `()`
535+ ```
536+
537+ Another problem you might be facing is this: suppose you've overloaded the `+`
538+ operator for some type `Foo` by implementing the `std::ops::Add` trait for
539+ `Foo`, but you find that using `+=` does not work, as in this example:
540+
541+ ```
542+ use std::ops::Add;
543+
544+ struct Foo(u32);
545+
546+ impl Add for Foo {
547+ type Output = Foo;
548+
549+ fn add(self, rhs: Foo) -> Foo {
550+ Foo(self.0 + rhs.0)
551+ }
552+ }
553+
554+ fn main() {
555+ let mut x: Foo = Foo(5);
556+ x += Foo(7); // error, `+= cannot be applied to types `Foo` and `Foo`
557+ }
558+ ```
559+
560+ This is because the binary assignment operators currently do not work off of
561+ traits, so it is not possible to overload them. See [RFC 953] for a proposal
562+ to change this.
563+
564+ [RFC 953]: https://github.com/rust-lang/rfcs/pull/953
461565"##
462566
463567}
@@ -478,15 +582,12 @@ register_diagnostics! {
478582 E0040 , // explicit use of destructor method
479583 E0044 , // foreign items may not have type parameters
480584 E0045 , // variadic function must have C calling convention
481- E0053 ,
482585 E0055 , // method has an incompatible type for trait
483586 E0057 , // method has an incompatible type for trait
484587 E0059 ,
485588 E0060 ,
486589 E0061 ,
487- E0066 ,
488590 E0068 ,
489- E0069 ,
490591 E0070 ,
491592 E0071 ,
492593 E0072 ,
@@ -606,7 +707,6 @@ register_diagnostics! {
606707 E0328 , // cannot implement Unsize explicitly
607708 E0366 , // dropck forbid specialization to concrete type or region
608709 E0367 , // dropck forbid specialization to predicate not in struct/enum
609- E0368 , // binary operation `<op>=` cannot be applied to types
610710 E0369 , // binary operation `<op>` cannot be applied to types
611711 E0371 , // impl Trait for Trait is illegal
612712 E0372 , // impl Trait for Trait where Trait is not object safe
0 commit comments