-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Show five traits implementation in help when there are exactly five #39804
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @eddyb (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
a9d451b
to
882f4a8
Compare
fn main() { | ||
Foo::<i32>::bar(&1i8); | ||
|
||
//~^ error: the trait `Foo<i32>` is not implemented for `i8`` |
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.
Are those two backticks at the end of the line intentional?
All other tests within ui/did_you_mean/
use a separate .stderr file. I think it's not possible to use this inline error notation here.
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.
You are right, I copied it from src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.rs
which has both but I did not noticed the stderr file.
impl Foo<u32> for i8 {} | ||
impl Foo<u64> for i8 {} | ||
impl Foo<bool> for i8 {} | ||
|
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.
Maybe you could add two more test cases (within this same file): one if there are just four implementations found and one if there are six (so that it says 'and 2 others').
5 | ||
} else { | ||
cmp::min(4, impl_candidates.len()) | ||
}; |
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 looks like a complex way to compute cmp::min(5, impl_candidates.len())
EDIT: yet it is not, if impl_candidates.len()
is greater than 5, this computation returns 4
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.
How about
let end = if impl_candidates.len() <= 5 {
impl_candidates.len()
} else {
4
};
? At least for me, it would make it easier to immediately grasp the behaviour.
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.
Good idea. I've added it and squashed the commits.
d3b96e3
to
d400ea0
Compare
d400ea0
to
ca54fc7
Compare
Looks good. Thanks for the PR! @bors r+ |
📌 Commit ca54fc7 has been approved by |
…jonathandturner Show five traits implementation in help when there are exactly five Fixes rust-lang#39802
…jonathandturner Show five traits implementation in help when there are exactly five Fixes rust-lang#39802
…jonathandturner Show five traits implementation in help when there are exactly five Fixes rust-lang#39802
…jonathandturner Show five traits implementation in help when there are exactly five Fixes rust-lang#39802
Fixes #39802