-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Suggest potentially missing binop trait bound (fix #73416) * Use structured suggestion for dereference in binop
- Loading branch information
Showing
10 changed files
with
169 additions
and
40 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
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,13 @@ | ||
// run-rustfix | ||
|
||
pub fn strip_prefix<'a, T: std::cmp::PartialEq>(s: &'a [T], prefix: &[T]) -> Option<&'a [T]> { | ||
let n = prefix.len(); | ||
if n <= s.len() { | ||
let (head, tail) = s.split_at(n); | ||
if head == prefix { //~ ERROR binary operation `==` cannot be applied to type `&[T]` | ||
return Some(tail); | ||
} | ||
} | ||
None | ||
} | ||
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 @@ | ||
// run-rustfix | ||
|
||
pub fn strip_prefix<'a, T>(s: &'a [T], prefix: &[T]) -> Option<&'a [T]> { | ||
let n = prefix.len(); | ||
if n <= s.len() { | ||
let (head, tail) = s.split_at(n); | ||
if head == prefix { //~ ERROR binary operation `==` cannot be applied to type `&[T]` | ||
return Some(tail); | ||
} | ||
} | ||
None | ||
} | ||
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,17 @@ | ||
error[E0369]: binary operation `==` cannot be applied to type `&[T]` | ||
--> $DIR/missing-trait-bound-for-op.rs:7:17 | ||
| | ||
LL | if head == prefix { | ||
| ---- ^^ ------ &[T] | ||
| | | ||
| &[T] | ||
| | ||
= note: the trait `std::cmp::PartialEq` is not implemented for `&[T]` | ||
help: consider restricting type parameter `T` | ||
| | ||
LL | pub fn strip_prefix<'a, T: std::cmp::PartialEq>(s: &'a [T], prefix: &[T]) -> Option<&'a [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