Skip to content

Add suggestion to multiple applicable items in scope error #51046

Closed
@spastorino

Description

@spastorino

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions