Skip to content
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

Merged
merged 1 commit into from
Feb 16, 2017

Conversation

seppo0010
Copy link
Contributor

Fixes #39802

@rust-highfive
Copy link
Collaborator

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.

@eddyb
Copy link
Member

eddyb commented Feb 14, 2017

r? @jonathandturner

@rust-highfive rust-highfive assigned sophiajt and unassigned eddyb Feb 14, 2017
fn main() {
Foo::<i32>::bar(&1i8);

//~^ error: the trait `Foo<i32>` is not implemented for `i8``
Copy link
Contributor

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.

Copy link
Contributor Author

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 {}

Copy link
Contributor

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())
};
Copy link
Contributor

@ranma42 ranma42 Feb 14, 2017

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@sophiajt
Copy link
Contributor

Looks good. Thanks for the PR!

@bors r+

@bors
Copy link
Contributor

bors commented Feb 14, 2017

📌 Commit ca54fc7 has been approved by jonathandturner

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Feb 15, 2017
…jonathandturner

Show five traits implementation in help when there are exactly five

Fixes rust-lang#39802
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Feb 15, 2017
…jonathandturner

Show five traits implementation in help when there are exactly five

Fixes rust-lang#39802
bors added a commit that referenced this pull request Feb 16, 2017
Rollup of 11 pull requests

- Successful merges: #39775, #39793, #39804, #39824, #39834, #39837, #39839, #39840, #39843, #39844, #39846
- Failed merges:
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Feb 16, 2017
…jonathandturner

Show five traits implementation in help when there are exactly five

Fixes rust-lang#39802
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Feb 16, 2017
…jonathandturner

Show five traits implementation in help when there are exactly five

Fixes rust-lang#39802
bors added a commit that referenced this pull request Feb 16, 2017
Rollup of 12 pull requests

- Successful merges: #39775, #39793, #39804, #39834, #39836, #39839, #39840, #39843, #39844, #39846, #39857, #39861
- Failed merges:
@bors bors merged commit ca54fc7 into rust-lang:master Feb 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants