Auto merge of #50161 - rizakrko:impl_note, r=estebank
added missing implementation hint Fixes [#50151](https://github.com/rust-lang/rust/issues/50151). Actually, i don't know, should following code `let x = |ref x: isize| { x += 1; };` emit `note: an implementation of std::ops::AddAssign might be missing for &isize` or `note: this is a reference to a type that + can be applied to; you need to dereference this variable once for this operation to work` or both
This commit is contained in:
commit
388df823e8
11 changed files with 202 additions and 81 deletions
|
|
@ -4,8 +4,7 @@ error[E0369]: binary operation `%` cannot be applied to type `&&{integer}`
|
|||
LL | x % 2 == 0
|
||||
| ^^^^^
|
||||
|
|
||||
= note: this is a reference to a type that `%` can be applied to; you need to dereference this variable once for this operation to work
|
||||
= note: an implementation of `std::ops::Rem` might be missing for `&&{integer}`
|
||||
= help: `%` can be used on '{integer}', you can dereference `x`: `*x`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0600]: cannot apply unary operator `!` to type `&'static str`
|
|||
--> $DIR/issue-28308.rs:12:5
|
||||
|
|
||||
LL | assert!("foo");
|
||||
| ^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^ cannot apply unary operator `!`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ LL | LinkedList::new() += 1; //~ ERROR E0368
|
|||
| -----------------^^^^^
|
||||
| |
|
||||
| cannot use `+=` on type `std::collections::LinkedList<_>`
|
||||
|
|
||||
= note: an implementation of `std::ops::AddAssign` might be missing for `std::collections::LinkedList<_>`
|
||||
|
||||
error[E0067]: invalid left-hand side expression
|
||||
--> $DIR/E0067.rs:14:5
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0600]: cannot apply unary operator `!` to type `&'static str`
|
|||
--> $DIR/E0600.rs:12:5
|
||||
|
|
||||
LL | !"a"; //~ ERROR E0600
|
||||
| ^^^^
|
||||
| ^^^^ cannot apply unary operator `!`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ LL | x += 2;
|
|||
| -^^^^^
|
||||
| |
|
||||
| cannot use `+=` on type `&str`
|
||||
|
|
||||
= note: an implementation of `std::ops::AddAssign` might be missing for `&str`
|
||||
|
||||
error[E0599]: no method named `z` found for type `&str` in the current scope
|
||||
--> $DIR/error-festival.rs:26:7
|
||||
|
|
@ -28,7 +30,9 @@ error[E0600]: cannot apply unary operator `!` to type `Question`
|
|||
--> $DIR/error-festival.rs:29:5
|
||||
|
|
||||
LL | !Question::Yes;
|
||||
| ^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^ cannot apply unary operator `!`
|
||||
|
|
||||
= note: an implementation of `std::ops::Not` might be missing for `Question`
|
||||
|
||||
error[E0604]: only `u8` can be cast as `char`, not `u32`
|
||||
--> $DIR/error-festival.rs:35:5
|
||||
|
|
|
|||
|
|
@ -2,13 +2,17 @@ error[E0600]: cannot apply unary operator `-` to type `usize`
|
|||
--> $DIR/feature-gate-negate-unsigned.rs:20:23
|
||||
|
|
||||
LL | let _max: usize = -1;
|
||||
| ^^
|
||||
| ^^ cannot apply unary operator `-`
|
||||
|
|
||||
= note: unsigned values cannot be negated
|
||||
|
||||
error[E0600]: cannot apply unary operator `-` to type `u8`
|
||||
--> $DIR/feature-gate-negate-unsigned.rs:24:14
|
||||
|
|
||||
LL | let _y = -x;
|
||||
| ^^
|
||||
| ^^ cannot apply unary operator `-`
|
||||
|
|
||||
= note: unsigned values cannot be negated
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ LL | let x = |ref x: isize| { x += 1; };
|
|||
| -^^^^^
|
||||
| |
|
||||
| cannot use `+=` on type `&isize`
|
||||
|
|
||||
= help: `+=` can be used on 'isize', you can dereference `x`: `*x`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0600]: cannot apply unary operator `!` to type `!`
|
|||
--> $DIR/expr_unary.rs:17:16
|
||||
|
|
||||
LL | let x: ! = ! { return; }; //~ ERROR unreachable
|
||||
| ^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^ cannot apply unary operator `!`
|
||||
|
||||
error: unreachable expression
|
||||
--> $DIR/expr_unary.rs:17:16
|
||||
|
|
|
|||
|
|
@ -14,3 +14,7 @@ fn main() {
|
|||
fn foo<T>(x: T, y: T) {
|
||||
let z = x + y; //~ ERROR binary operation `+` cannot be applied to type `T`
|
||||
}
|
||||
|
||||
fn bar<T>(x: T) {
|
||||
x += x; //~ ERROR binary assignment operation `+=` cannot be applied to type `T`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,17 @@ LL | let z = x + y; //~ ERROR binary operation `+` cannot be applied to type
|
|||
|
|
||||
= note: `T` might need a bound for `std::ops::Add`
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0368]: binary assignment operation `+=` cannot be applied to type `T`
|
||||
--> $DIR/missing_trait_impl.rs:19:5
|
||||
|
|
||||
LL | x += x; //~ ERROR binary assignment operation `+=` cannot be applied to type `T`
|
||||
| -^^^^^
|
||||
| |
|
||||
| cannot use `+=` on type `T`
|
||||
|
|
||||
= note: `T` might need a bound for `std::ops::AddAssign`
|
||||
|
||||
For more information about this error, try `rustc --explain E0369`.
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors occurred: E0368, E0369.
|
||||
For more information about an error, try `rustc --explain E0368`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue