- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code:
trait A {
    fn method(&self) {
        println!("A");
    }
}
trait B {
    fn method(&self) {
        println!("B");
    }
}
struct Empty {}
impl A for Empty {}
impl B for Empty {}
fn main() {
    Empty {}.method();
}Error:
error[E0034]: multiple applicable items in scope
  --> src/main.rs:19:14
   |
19 |     Empty {}.method();
   |              ^^^^^^ multiple `method` found
   |
note: candidate #1 is defined in an impl of the trait `A` for the type `Empty`
  --> src/main.rs:2:5
   |
2  |     fn method(&self) {
   |     ^^^^^^^^^^^^^^^^
   = help: to disambiguate the method call, write `A::method(Empty {})` instead
note: candidate #2 is defined in an impl of the trait `B` for the type `Empty`
  --> src/main.rs:8:5
   |
8  |     fn method(&self) {
   |     ^^^^^^^^^^^^^^^^
   = help: to disambiguate the method call, write `B::method(Empty {})` instead
Should be A::method(&Empty {}) and B::method(&Empty {}).
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.