Skip to content

Add suggestion to multiple applicable items in scope error #51046

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
spastorino opened this issue May 24, 2018 · 3 comments · Fixed by #62921
Closed

Add suggestion to multiple applicable items in scope error #51046

spastorino opened this issue May 24, 2018 · 3 comments · Fixed by #62921
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@spastorino
Copy link
Member

When your type implements two traits with the same fn signatures, there's an ambiguity that can be solved by calling Trait::function(instance_of_type). The error is perfect but could add that as suggestion.

For instance ...

error[E0034]: multiple applicable items in scope
    --> librustc/ty/sty.rs:1187:13
     |
1187 |         vid.index()
     |             ^^^^^ multiple `index` found
     |
note: candidate #1 is defined in an impl of the trait `polonius_engine::Atom` for the type `ty::sty::RegionVid`
    --> librustc/ty/sty.rs:1174:5
     |
1174 |     fn index(self) -> usize {
     |     ^^^^^^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in an impl of the trait `rustc_data_structures::indexed_vec::Idx` for the type `ty::sty::RegionVid`
    --> librustc/ty/sty.rs:1167:1
     |
1167 | / newtype_index!(RegionVid
1168 | |     {
1169 | |         pub idx
1170 | |         DEBUG_FORMAT = custom,
1171 | |     });
     | |_______^
     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0034`.

Could say ...

Suggestion: use Idx::index(vid) or Atom::index(vid)

@spastorino spastorino added the A-diagnostics Area: Messages for errors, warnings, and lints label May 24, 2018
@nikomatsakis nikomatsakis added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 24, 2018
@nikomatsakis
Copy link
Contributor

seems like an easy win to me!

@omershlo
Copy link

omershlo commented Sep 4, 2018

funny, I just used this open issue to understand how to solve this error. Please add the above suggestion of calling the trait. It's extremely helpful.

@XAMPPRocky XAMPPRocky added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Oct 2, 2018
@hcpl
Copy link

hcpl commented Mar 8, 2019

This looks like the same issue as #40471.

iluuu1994 added a commit to iluuu1994/rust that referenced this issue Jul 24, 2019
Centril added a commit to Centril/rust that referenced this issue Jul 24, 2019
…isambiguation, r=estebank

Add method disambiguation help for trait implementation

Closes rust-lang#51046
Closes rust-lang#40471
Centril added a commit to Centril/rust that referenced this issue Jul 25, 2019
…isambiguation, r=estebank

Add method disambiguation help for trait implementation

Closes rust-lang#51046
Closes rust-lang#40471
Centril added a commit to Centril/rust that referenced this issue Jul 25, 2019
…isambiguation, r=estebank

Add method disambiguation help for trait implementation

Closes rust-lang#51046
Closes rust-lang#40471
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants