-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #73674 - estebank:op-trait-bound-suggestion, r=davidtwco
Tweak binop errors * Suggest potentially missing binop trait bound (fix #73416) * Use structured suggestion for dereference in binop
- Loading branch information
Showing
14 changed files
with
328 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// run-rustfix | ||
fn main() { | ||
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9]; | ||
let vr = v.iter().filter(|x| { | ||
*x % 2 == 0 | ||
//~^ ERROR cannot mod `&&{integer}` by `{integer}` | ||
}); | ||
println!("{:?}", vr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// run-rustfix | ||
fn main() { | ||
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9]; | ||
let vr = v.iter().filter(|x| { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pub fn foo<T>(s: S<T>, t: S<T>) { | ||
let _ = s == t; //~ ERROR binary operation `==` cannot be applied to type `S<T>` | ||
} | ||
|
||
struct S<T>(T); | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error[E0369]: binary operation `==` cannot be applied to type `S<T>` | ||
--> $DIR/invalid-bin-op.rs:2:15 | ||
| | ||
LL | let _ = s == t; | ||
| - ^^ - S<T> | ||
| | | ||
| S<T> | ||
| | ||
= note: the trait `std::cmp::PartialEq` is not implemented for `S<T>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0369`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// run-rustfix | ||
|
||
pub fn foo<T: std::cmp::PartialEq>(s: &[T], t: &[T]) { | ||
let _ = s == t; //~ ERROR binary operation `==` cannot be applied to type `&[T]` | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// run-rustfix | ||
|
||
pub fn foo<T>(s: &[T], t: &[T]) { | ||
let _ = s == t; //~ ERROR binary operation `==` cannot be applied to type `&[T]` | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error[E0369]: binary operation `==` cannot be applied to type `&[T]` | ||
--> $DIR/missing-trait-bound-for-op.rs:4:15 | ||
| | ||
LL | let _ = s == t; | ||
| - ^^ - &[T] | ||
| | | ||
| &[T] | ||
| | ||
help: consider restricting type parameter `T` | ||
| | ||
LL | pub fn foo<T: std::cmp::PartialEq>(s: &[T], t: &[T]) { | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0369`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters