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

E0034 should provide the disambiguated syntax for the candidates #37767

Closed
gnzlbg opened this issue Nov 14, 2016 · 0 comments
Closed

E0034 should provide the disambiguated syntax for the candidates #37767

gnzlbg opened this issue Nov 14, 2016 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 14, 2016

Currently, with the following code:

trait A { fn foo(&self) {} }
trait B : A { fn foo(&self) {} }

fn bar<T: B>(a: &T) {
  a.foo()
}

fn main() {}

prints the following error message:

error[E0034]: multiple applicable items in scope
 --> <anon>:5:5
  |
5 |   a.foo()
  |     ^^^ multiple `foo` found
  |
note: candidate #1 is defined in the trait `A`
 --> <anon>:1:11
  |
1 | trait A { fn foo(&self) {} }
  |           ^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `B`
 --> <anon>:2:15
  |
2 | trait B : A { fn foo(&self) {} }
  |               ^^^^^^^^^^^^^^^^

error: aborting due to previous error

It would be nice if it would tell me what exactly do I need to type in order to choose candidate 1 or candidate 2. In particular, when associated types, Input/Output parameters, ... are involved, the disambiguation syntax can be tricky.

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Nov 15, 2016
bors added a commit that referenced this issue Jan 18, 2017
E0034: provide disambiguated syntax for candidates

For a given file

```rust
trait A { fn foo(&self) {} }
trait B : A { fn foo(&self) {} }

fn bar<T: B>(a: &T) {
  a.foo()
}
```

provide the following output

```
error[E0034]: multiple applicable items in scope
 --> file.rs:6:5
  |
6 |   a.foo(1)
  |     ^^^ multiple `foo` found
  |
note: candidate #1 is defined in the trait `A`
 --> file.rs:2:11
  |
2 | trait A { fn foo(&self, a: usize) {} }
  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: to use it here write `A::foo(&a, 1)` instead
 --> file.rs:6:5
  |
6 |   a.foo(1)
  |     ^^^
note: candidate #2 is defined in the trait `B`
 --> file.rs:3:15
  |
3 | trait B : A { fn foo(&self, a: usize) {} }
  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: to use it here write `B::foo(&a, 1)` instead
 --> file.rs:6:5
  |
6 |   a.foo(1)
  |     ^^^
```

Fix #37767.
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

No branches or pull requests

2 participants