diff options
| author | bors <bors@rust-lang.org> | 2017-05-23 00:36:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-05-23 00:36:56 +0000 |
| commit | 2e9139197e908435673c62a14381fbd4f8166319 (patch) | |
| tree | 19b77875f70eb6c04366ac3b21ae22636f21f1d4 /src/test/ui | |
| parent | 81734e0e06d24cf580dd5352c64d10110e4d3b7b (diff) | |
| parent | 747287a2b3b6649d59cfd11be1fb32e667f71a3f (diff) | |
| download | rust-2e9139197e908435673c62a14381fbd4f8166319.tar.gz rust-2e9139197e908435673c62a14381fbd4f8166319.zip | |
Auto merge of #41559 - GuillaumeGomez:partial-eq-msg, r=estebank
Add better error message when == operator is badly used
Part of #40660.
With the following code:
```rust
fn foo<T: PartialEq>(a: &T, b: T) {
a == b;
}
fn main() {
foo(&1, 1);
}
```
It prints:
```
error[E0277]: the trait bound `&T: std::cmp::PartialEq<T>` is not satisfied
--> test.rs:2:5
|
2 | a == b;
| ^^^^^^ can't compare `&T` with `T`
|
= help: the trait `std::cmp::PartialEq<T>` is not implemented for `&T`
= help: consider adding a `where &T: std::cmp::PartialEq<T>` bound
error: aborting due to previous error
```
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/impl-trait/equality.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/mismatched_types/binops.stderr | 28 | ||||
| -rw-r--r-- | src/test/ui/mismatched_types/cast-rfc0401.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/resolve/issue-5035-2.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/span/multiline-span-simple.stderr | 4 |
5 files changed, 24 insertions, 24 deletions
diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr index bd024d6766e..08d9043f65e 100644 --- a/src/test/ui/impl-trait/equality.stderr +++ b/src/test/ui/impl-trait/equality.stderr @@ -11,9 +11,9 @@ error[E0277]: the trait bound `u32: std::ops::Add<impl Foo>` is not satisfied --> $DIR/equality.rs:34:9 | 34 | n + sum_to(n - 1) - | ^^^^^^^^^^^^^^^^^ the trait `std::ops::Add<impl Foo>` is not implemented for `u32` + | ^^^^^^^^^^^^^^^^^ no implementation for `u32 + impl Foo` | - = note: no implementation for `u32 + impl Foo` + = help: the trait `std::ops::Add<impl Foo>` is not implemented for `u32` error[E0308]: mismatched types --> $DIR/equality.rs:53:18 diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr index a0f7ff65870..773bf0593c5 100644 --- a/src/test/ui/mismatched_types/binops.stderr +++ b/src/test/ui/mismatched_types/binops.stderr @@ -2,57 +2,57 @@ error[E0277]: the trait bound `{integer}: std::ops::Add<std::option::Option<{int --> $DIR/binops.rs:12:5 | 12 | 1 + Some(1); - | ^^^^^^^^^^^ the trait `std::ops::Add<std::option::Option<{integer}>>` is not implemented for `{integer}` + | ^^^^^^^^^^^ no implementation for `{integer} + std::option::Option<{integer}>` | - = note: no implementation for `{integer} + std::option::Option<{integer}>` + = help: the trait `std::ops::Add<std::option::Option<{integer}>>` is not implemented for `{integer}` error[E0277]: the trait bound `usize: std::ops::Sub<std::option::Option<{integer}>>` is not satisfied --> $DIR/binops.rs:13:5 | 13 | 2 as usize - Some(1); - | ^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Sub<std::option::Option<{integer}>>` is not implemented for `usize` + | ^^^^^^^^^^^^^^^^^^^^ no implementation for `usize - std::option::Option<{integer}>` | - = note: no implementation for `usize - std::option::Option<{integer}>` + = help: the trait `std::ops::Sub<std::option::Option<{integer}>>` is not implemented for `usize` error[E0277]: the trait bound `{integer}: std::ops::Mul<()>` is not satisfied --> $DIR/binops.rs:14:5 | 14 | 3 * (); - | ^^^^^^ the trait `std::ops::Mul<()>` is not implemented for `{integer}` + | ^^^^^^ no implementation for `{integer} * ()` | - = note: no implementation for `{integer} * ()` + = help: the trait `std::ops::Mul<()>` is not implemented for `{integer}` error[E0277]: the trait bound `{integer}: std::ops::Div<&str>` is not satisfied --> $DIR/binops.rs:15:5 | 15 | 4 / ""; - | ^^^^^^ the trait `std::ops::Div<&str>` is not implemented for `{integer}` + | ^^^^^^ no implementation for `{integer} / &str` | - = note: no implementation for `{integer} / &str` + = help: the trait `std::ops::Div<&str>` is not implemented for `{integer}` error[E0277]: the trait bound `{integer}: std::cmp::PartialEq<std::string::String>` is not satisfied --> $DIR/binops.rs:16:5 | 16 | 5 < String::new(); - | ^^^^^^^^^^^^^^^^^ the trait `std::cmp::PartialEq<std::string::String>` is not implemented for `{integer}` + | ^^^^^^^^^^^^^^^^^ can't compare `{integer}` with `std::string::String` | - = note: can't compare `{integer}` with `std::string::String` + = help: the trait `std::cmp::PartialEq<std::string::String>` is not implemented for `{integer}` error[E0277]: the trait bound `{integer}: std::cmp::PartialOrd<std::string::String>` is not satisfied --> $DIR/binops.rs:16:5 | 16 | 5 < String::new(); - | ^^^^^^^^^^^^^^^^^ the trait `std::cmp::PartialOrd<std::string::String>` is not implemented for `{integer}` + | ^^^^^^^^^^^^^^^^^ can't compare `{integer}` with `std::string::String` | - = note: can't compare `{integer}` with `std::string::String` + = help: the trait `std::cmp::PartialOrd<std::string::String>` is not implemented for `{integer}` error[E0277]: the trait bound `{integer}: std::cmp::PartialEq<std::result::Result<{integer}, _>>` is not satisfied --> $DIR/binops.rs:17:5 | 17 | 6 == Ok(1); - | ^^^^^^^^^^ the trait `std::cmp::PartialEq<std::result::Result<{integer}, _>>` is not implemented for `{integer}` + | ^^^^^^^^^^ can't compare `{integer}` with `std::result::Result<{integer}, _>` | - = note: can't compare `{integer}` with `std::result::Result<{integer}, _>` + = help: the trait `std::cmp::PartialEq<std::result::Result<{integer}, _>>` is not implemented for `{integer}` error: aborting due to 7 previous errors diff --git a/src/test/ui/mismatched_types/cast-rfc0401.stderr b/src/test/ui/mismatched_types/cast-rfc0401.stderr index 7fd10f3cb68..8853b35eb8b 100644 --- a/src/test/ui/mismatched_types/cast-rfc0401.stderr +++ b/src/test/ui/mismatched_types/cast-rfc0401.stderr @@ -210,18 +210,18 @@ error[E0277]: the trait bound `[u8]: std::marker::Sized` is not satisfied --> $DIR/cast-rfc0401.rs:63:13 | 63 | let _ = fat_v as *const Foo; - | ^^^^^ the trait `std::marker::Sized` is not implemented for `[u8]` + | ^^^^^ `[u8]` does not have a constant size known at compile-time | - = note: `[u8]` does not have a constant size known at compile-time + = help: the trait `std::marker::Sized` is not implemented for `[u8]` = note: required for the cast to the object type `Foo` error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied --> $DIR/cast-rfc0401.rs:72:13 | 72 | let _ = a as *const Foo; - | ^ the trait `std::marker::Sized` is not implemented for `str` + | ^ `str` does not have a constant size known at compile-time | - = note: `str` does not have a constant size known at compile-time + = help: the trait `std::marker::Sized` is not implemented for `str` = note: required for the cast to the object type `Foo` error: casting `&{float}` as `f32` is invalid diff --git a/src/test/ui/resolve/issue-5035-2.stderr b/src/test/ui/resolve/issue-5035-2.stderr index 72b1578e0d0..791b20725f3 100644 --- a/src/test/ui/resolve/issue-5035-2.stderr +++ b/src/test/ui/resolve/issue-5035-2.stderr @@ -2,9 +2,9 @@ error[E0277]: the trait bound `I + 'static: std::marker::Sized` is not satisfied --> $DIR/issue-5035-2.rs:14:8 | 14 | fn foo(_x: K) {} //~ ERROR: `I + 'static: std::marker::Sized` is not satisfied - | ^^ the trait `std::marker::Sized` is not implemented for `I + 'static` + | ^^ `I + 'static` does not have a constant size known at compile-time | - = note: `I + 'static` does not have a constant size known at compile-time + = help: the trait `std::marker::Sized` is not implemented for `I + 'static` = note: all local variables must have a statically known size error: aborting due to previous error diff --git a/src/test/ui/span/multiline-span-simple.stderr b/src/test/ui/span/multiline-span-simple.stderr index 843c1e811d5..44d5379648d 100644 --- a/src/test/ui/span/multiline-span-simple.stderr +++ b/src/test/ui/span/multiline-span-simple.stderr @@ -7,9 +7,9 @@ error[E0277]: the trait bound `u32: std::ops::Add<()>` is not satisfied 25 | | bar(x, 26 | | 27 | | y), - | |______________^ the trait `std::ops::Add<()>` is not implemented for `u32` + | |______________^ no implementation for `u32 + ()` | - = note: no implementation for `u32 + ()` + = help: the trait `std::ops::Add<()>` is not implemented for `u32` error: aborting due to previous error |
