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

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

Closed
Havvy opened this issue Mar 13, 2017 · 1 comment · Fixed by #62921
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@Havvy
Copy link
Contributor

Havvy commented Mar 13, 2017

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().

@bstrie bstrie added the A-diagnostics Area: Messages for errors, warnings, and lints label Mar 22, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
@hcpl
Copy link

hcpl commented Mar 8, 2019

Turns out, rustc does provide suggestions since Rust 1.16, but only for trait objects, not concrete values. This can be seen in #58988.

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
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 C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants