Skip to content

In Multiple Applicable Items in Scope eror, add disambiguation syntax suggestion note #40471

Closed
@Havvy

Description

@Havvy
struct Runner;

trait RunA {
  fn run();
}

trait RunB {
  fn run();
}

impl RunA for Runner {
  fn run() {
    println!("{}", "A");
  }
}

impl RunB for Runner {
  fn run() {
    println!("{}", "B");
  }
}

fn main() {
  Runner::run();
}

This gives the following error:

rustc 1.17.0-nightly (b1e31766d 2017-03-03)
error[E0034]: multiple applicable items in scope
  --> <anon>:24:3
   |
24 |   Runner::run();
   |   ^^^^^^^^^^^ multiple `run` found
   |
note: candidate #1 is defined in an impl of the trait `RunA` for the type `Runner`
  --> <anon>:12:3
   |
12 |     fn run() {
   |  ___^ starting here...
13 | |     println!("{}", "A");
14 | |   }
   | |___^ ...ending here
note: candidate #2 is defined in an impl of the trait `RunB` for the type `Runner`
  --> <anon>:18:3
   |
18 |     fn run() {
   |  ___^ starting here...
19 | |     println!("{}", "B");
20 | |   }
   | |___^ ...ending here

error: aborting due to previous error

After each note: candidate #N note, there should be another note, note: to use candidate #N, use <Runner as trait>::run().

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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions