-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explicit help message for binop type mismatch #40565
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,55 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/equality.rs:25:5 | ||
| | ||
25 | 0_u32 | ||
| ^^^^^ expected i32, found u32 | ||
| | ||
= note: expected type `i32` | ||
found type `u32` | ||
|
||
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` | ||
| | ||
= note: no implementation for `u32 + impl Foo` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/equality.rs:53:18 | ||
| | ||
53 | let _: u32 = hide(0_u32); | ||
| ^^^^^^^^^^^ expected u32, found anonymized type | ||
| | ||
= note: expected type `u32` | ||
found type `impl Foo` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/equality.rs:59:18 | ||
| | ||
59 | let _: i32 = Leak::leak(hide(0_i32)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found associated type | ||
| | ||
= note: expected type `i32` | ||
found type `<impl Foo as Leak>::T` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/equality.rs:66:10 | ||
| | ||
66 | x = (x.1, | ||
| ^^^ expected u32, found i32 | ||
| | ||
= note: expected type `impl Foo` (u32) | ||
found type `impl Foo` (i32) | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/equality.rs:69:10 | ||
| | ||
69 | x.0); | ||
| ^^^ expected i32, found u32 | ||
| | ||
= note: expected type `impl Foo` (i32) | ||
found type `impl Foo` (u32) | ||
|
||
error: aborting due to 6 previous errors | ||
|
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,18 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
fn main() { | ||
1 + Some(1); | ||
2 as usize - Some(1); | ||
3 * (); | ||
4 / ""; | ||
5 < String::new(); | ||
6 == Ok(1); | ||
} |
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,58 @@ | ||
error[E0277]: the trait bound `{integer}: std::ops::Add<std::option::Option<{integer}>>` is not satisfied | ||
--> $DIR/binops.rs:12:5 | ||
| | ||
12 | 1 + Some(1); | ||
| ^^^^^^^^^^^ the trait `std::ops::Add<std::option::Option<{integer}>>` is not implemented for `{integer}` | ||
| | ||
= note: no implementation for `{integer} + std::option::Option<{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` | ||
| | ||
= note: no implementation for `usize - std::option::Option<{integer}>` | ||
|
||
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}` | ||
| | ||
= note: no implementation 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}` | ||
| | ||
= note: no implementation for `{integer} / &str` | ||
|
||
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}` | ||
| | ||
= note: can't compare `{integer}` with `std::string::String` | ||
|
||
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}` | ||
| | ||
= note: can't compare `{integer}` with `std::string::String` | ||
|
||
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}` | ||
| | ||
= note: can't compare `{integer}` with `std::result::Result<{integer}, _>` | ||
|
||
error: aborting due to 7 previous errors | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can change all
on_unimplemented
messages to be labels by making this a.span_label
call. Not sure it's a good idea.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a bad idea to do that for all cases, but I've been considering the possibility of having a way to configure wether it is shown as a note or as the span's label. I'm thinking that it could either accomplished by changing the parsing of attributes to accept extra arguments, or simply have it change behavior when the
rustc_on_unimplemented
text starts withlabel:
. It might be too more magic than I'm comfortable with, though.