forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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 rust-lang#126925 - surechen:fix_125631, r=compiler-errors Change E0369 to give note informations for foreign items. Change E0369 to give note informations for foreign items. Make it easy for developers to understand why the binop cannot be applied. fixes rust-lang#125631
- Loading branch information
Showing
11 changed files
with
219 additions
and
26 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
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,16 @@ | ||
use std::io::{Error, ErrorKind}; | ||
use std::thread; | ||
|
||
struct T1; | ||
struct T2; | ||
|
||
fn main() { | ||
(Error::new(ErrorKind::Other, "1"), T1, 1) == (Error::new(ErrorKind::Other, "1"), T1, 2); | ||
//~^ERROR binary operation `==` cannot be applied to type | ||
(Error::new(ErrorKind::Other, "2"), thread::current()) | ||
== (Error::new(ErrorKind::Other, "2"), thread::current()); | ||
//~^ERROR binary operation `==` cannot be applied to type | ||
(Error::new(ErrorKind::Other, "4"), thread::current(), T1, T2) | ||
== (Error::new(ErrorKind::Other, "4"), thread::current(), T1, T2); | ||
//~^ERROR binary operation `==` cannot be applied to type | ||
} |
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,75 @@ | ||
error[E0369]: binary operation `==` cannot be applied to type `(std::io::Error, T1, {integer})` | ||
--> $DIR/binary-op-not-allowed-issue-125631.rs:8:48 | ||
| | ||
LL | (Error::new(ErrorKind::Other, "1"), T1, 1) == (Error::new(ErrorKind::Other, "1"), T1, 2); | ||
| ------------------------------------------ ^^ ------------------------------------------ (std::io::Error, T1, {integer}) | ||
| | | ||
| (std::io::Error, T1, {integer}) | ||
| | ||
note: an implementation of `PartialEq` might be missing for `T1` | ||
--> $DIR/binary-op-not-allowed-issue-125631.rs:4:1 | ||
| | ||
LL | struct T1; | ||
| ^^^^^^^^^ must implement `PartialEq` | ||
note: the foreign item type `std::io::Error` doesn't implement `PartialEq` | ||
--> $SRC_DIR/std/src/io/error.rs:LL:COL | ||
| | ||
= note: not implement `PartialEq` | ||
help: consider annotating `T1` with `#[derive(PartialEq)]` | ||
| | ||
LL + #[derive(PartialEq)] | ||
LL | struct T1; | ||
| | ||
|
||
error[E0369]: binary operation `==` cannot be applied to type `(std::io::Error, Thread)` | ||
--> $DIR/binary-op-not-allowed-issue-125631.rs:11:9 | ||
| | ||
LL | (Error::new(ErrorKind::Other, "2"), thread::current()) | ||
| ------------------------------------------------------ (std::io::Error, Thread) | ||
LL | == (Error::new(ErrorKind::Other, "2"), thread::current()); | ||
| ^^ ------------------------------------------------------ (std::io::Error, Thread) | ||
| | ||
note: the foreign item types don't implement required traits for this operation to be valid | ||
--> $SRC_DIR/std/src/io/error.rs:LL:COL | ||
| | ||
= note: not implement `PartialEq` | ||
--> $SRC_DIR/std/src/thread/mod.rs:LL:COL | ||
| | ||
= note: not implement `PartialEq` | ||
|
||
error[E0369]: binary operation `==` cannot be applied to type `(std::io::Error, Thread, T1, T2)` | ||
--> $DIR/binary-op-not-allowed-issue-125631.rs:14:9 | ||
| | ||
LL | (Error::new(ErrorKind::Other, "4"), thread::current(), T1, T2) | ||
| -------------------------------------------------------------- (std::io::Error, Thread, T1, T2) | ||
LL | == (Error::new(ErrorKind::Other, "4"), thread::current(), T1, T2); | ||
| ^^ -------------------------------------------------------------- (std::io::Error, Thread, T1, T2) | ||
| | ||
note: the following types would have to `impl` their required traits for this operation to be valid | ||
--> $DIR/binary-op-not-allowed-issue-125631.rs:4:1 | ||
| | ||
LL | struct T1; | ||
| ^^^^^^^^^ must implement `PartialEq` | ||
LL | struct T2; | ||
| ^^^^^^^^^ must implement `PartialEq` | ||
note: the foreign item types don't implement required traits for this operation to be valid | ||
--> $SRC_DIR/std/src/io/error.rs:LL:COL | ||
| | ||
= note: not implement `PartialEq` | ||
--> $SRC_DIR/std/src/thread/mod.rs:LL:COL | ||
| | ||
= note: not implement `PartialEq` | ||
help: consider annotating `T1` with `#[derive(PartialEq)]` | ||
| | ||
LL + #[derive(PartialEq)] | ||
LL | struct T1; | ||
| | ||
help: consider annotating `T2` with `#[derive(PartialEq)]` | ||
| | ||
LL + #[derive(PartialEq)] | ||
LL | struct T2; | ||
| | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
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
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
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