-
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.
Auto merge of #94034 - willcrichton:fix-trait-suggestion-for-binops, …
…r=estebank Fix incorrect suggestion for trait bounds involving binary operators This PR fixes #93927, #92347, #93744 by replacing the bespoke trait-suggestion logic in `op.rs` with a more common code path. The downside is that this fix causes some suggestions to not include an `Output=` type, reducing their usefulness. Note that this causes one case in the `missing-bounds.rs` test to fail rustfix. So I would need to move that code into a separate non-fix test if this PR is otherwise acceptable.
- Loading branch information
Showing
10 changed files
with
109 additions
and
161 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,20 @@ | ||
// Regression test for #93927: suggested trait bound for T should be Eq, not PartialEq | ||
struct MyType<T>(T); | ||
|
||
impl<T> PartialEq for MyType<T> | ||
where | ||
T: Eq, | ||
{ | ||
fn eq(&self, other: &Self) -> bool { | ||
true | ||
} | ||
} | ||
|
||
fn cond<T: PartialEq>(val: MyType<T>) -> bool { | ||
val == val | ||
//~^ ERROR binary operation `==` cannot be applied to type `MyType<T>` | ||
} | ||
|
||
fn main() { | ||
cond(MyType(0)); | ||
} |
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 `MyType<T>` | ||
--> $DIR/issue-93927.rs:14:9 | ||
| | ||
LL | val == val | ||
| --- ^^ --- MyType<T> | ||
| | | ||
| MyType<T> | ||
| | ||
help: consider further restricting this bound | ||
| | ||
LL | fn cond<T: PartialEq + std::cmp::Eq>(val: MyType<T>) -> bool { | ||
| ++++++++++++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0369`. |
This file was deleted.
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
// run-rustfix | ||
|
||
use std::ops::Add; | ||
|
||
struct A<B>(B); | ||
|
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
Oops, something went wrong.