-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Add notes for missing PartialEq and PartialOrd, closes #28837 #28933
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
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -0,0 +1,20 @@ | |||
struct A; |
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.
This file I believe will need a license to pass make tidy
Perhaps this could also handle all other binary operations? I think we've basically got a trait for all of them, so it could print a message out for each. |
I guess it's not possible to use the |
I've pushed a new commit that adds notes for all relevant It should be more like "it is not implemented by type However, the ideal note would say exactly which type does not have an Consider
Now the note would look like Note that this does not happen when Do you have any pointers where to look in order to improve the note in the |
945c283
to
77efe39
Compare
I'm not 100% sure how the deriving case could be improved, but dropping the "or one of its type arguments" seems fine to me, the qualification of "might" is probably good enough for "this message isn't always correct" |
Ok, I dropped the "or one of its type arguments" from the message. I still think handling the deriving case better would be good, as the new note is still somewhat confusing in the case @AndiDog mentioned in the issue, especially for beginners I think. But maybe improving it something to do in another pull request? |
@@ -191,6 +191,27 @@ fn check_overloaded_binop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, | |||
"binary operation `{}` cannot be applied to type `{}`", | |||
hir_util::binop_to_string(op.node), | |||
lhs_ty); | |||
let (display_note, missing_trait) = match op.node { | |||
hir::BiAdd => (true, "std::ops::Add"), |
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.
This may be more idiomatically done via Some("...")
with a None
at the end followed by a if let Some(missing_trait) = display_note
at the printing location.
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.
Thanks, I've updated the commit.
1e0c120
to
da16902
Compare
@bors: r+ da169028e3093ea6e74d50be3750efca9f3465fc Thanks! |
⌛ Testing commit da16902 with merge a72423a... |
💔 Test failed - auto-mac-64-opt |
da16902
to
b21ae1a
Compare
Unfortunately there was a trailing whitespace (sorry for that). I've updated the commit. |
Is it possible bors missed this PR? |
@bors r=alexcrichton |
📌 Commit b21ae1a has been approved by |
@bors retry |
Ok, now it's back on the board |
Wow that was fast. Thanks you very much for your swift response :) |
this PR adds notes for missing `PartialEq` and `PartialOrd`. I've added a test case but it seems like `NOTE` is ignored by the test runner. #28837
this PR adds notes for missing
PartialEq
andPartialOrd
. I've added a test case but it seems likeNOTE
is ignored by the test runner.#28837