Skip to content

added missing implementation hint #50161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍


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`.