Skip to content

Commit

Permalink
Auto merge of #50161 - rizakrko:impl_note, r=estebank
Browse files Browse the repository at this point in the history
added missing implementation hint

Fixes [#50151](#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
  • Loading branch information
bors committed May 11, 2018
2 parents 0cd4650 + 17c56d4 commit 388df82
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 80 deletions.
235 changes: 165 additions & 70 deletions src/librustc_typeck/check/op.rs

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/test/ui/binary-op-on-double-ref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/codemap_tests/issue-28308.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/error-codes/E0067.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0600.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion src/test/ui/error-festival.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/test/ui/feature-gate-negate-unsigned.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/issue-5239-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/reachable/expr_unary.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/type-check/missing_trait_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}
15 changes: 13 additions & 2 deletions src/test/ui/type-check/missing_trait_impl.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0369`.
Some errors occurred: E0368, E0369.
For more information about an error, try `rustc --explain E0368`.

0 comments on commit 388df82

Please sign in to comment.