Skip to content

Trait suggestions suggest the same trait multiple times #21405

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

Closed
alexcrichton opened this issue Jan 19, 2015 · 0 comments · Fixed by #21421
Closed

Trait suggestions suggest the same trait multiple times #21405

alexcrichton opened this issue Jan 19, 2015 · 0 comments · Fixed by #21421
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@alexcrichton
Copy link
Member

fn foo<F>(f: F) where F: FnMut(usize) {}

fn main() {                            
    foo(|s| s.is_empty())              
}                                      
$ rustc foo.rs
foo.rs:4:15: 4:25 error: type `usize` does not implement any method in scope named `is_empty`
foo.rs:4     foo(|s| s.is_empty())
                       ^~~~~~~~~~
foo.rs:4:25: 4:25 help: methods from traits can only be called if the trait is implemented and in scope; no such traits are but the following traits define a method `is_empty`:
foo.rs:4:25: 4:25 help: candidate #1: `core::slice::SliceExt`
foo.rs:4:25: 4:25 help: candidate #2: `core::slice::SliceExt`
foo.rs:4:25: 4:25 help: candidate #3: `core::str::StrExt`
foo.rs:4:25: 4:25 help: candidate #4: `core::str::StrExt`
foo.rs:4:25: 4:25 help: candidate #5: `collections::slice::SliceExt`
foo.rs:4:25: 4:25 help: candidate #6: `collections::slice::SliceExt`
foo.rs:4:25: 4:25 help: candidate #7: `collections::slice::SliceExt`
foo.rs:4:25: 4:25 help: candidate #8: `collections::str::StrExt`
foo.rs:4:25: 4:25 help: candidate #9: `collections::str::StrExt`
foo.rs:4:25: 4:25 help: candidate #10: `collections::str::StrExt`
error: aborting due to previous error

cc @huonw

Perhaps each trait could be suggested at most once? We may also want to work out the core/collections/std split as the only traits listed should probably be std::str::StrExt and std::slice::SliceExt, but that's also a separate bug.

@alexcrichton alexcrichton added the A-diagnostics Area: Messages for errors, warnings, and lints label Jan 19, 2015
huonw added a commit to huonw/rust that referenced this issue Jan 20, 2015
This is clearly useless, the user doesn't need to know that they could
implement/import `foo::bar::Baz` 4 times.

Fixes rust-lang#21405.
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 21, 2015
This is clearly useless, the user doesn't need to know that they could
implement/import `foo::bar::Baz` 4 times.

Fixes rust-lang#21405.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant