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

Suggested fix doesn't work in error [E0034] #116703

Closed
tae-soo-kim opened this issue Oct 13, 2023 · 0 comments · Fixed by #116713
Closed

Suggested fix doesn't work in error [E0034] #116703

tae-soo-kim opened this issue Oct 13, 2023 · 0 comments · Fixed by #116713
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tae-soo-kim
Copy link
Contributor

Code

trait A {
    fn foo(&self);
}

trait B {
    fn foo(&self);
}

struct S;

impl A for S {
    fn foo(&self) {}
}

impl B for S {
    fn foo(&self) {}
}

fn main() {
    let s = S;
    S::foo(&s);
}

Current output

help: disambiguate the method for candidate #1
   |
21 |     <&S as A>::foo(&s);
   |     ~~~~~~~~~~~

Desired output

help: disambiguate the method for candidate #1
   |
21 |     <S as A>::foo(&s);
   |     ~~~~~~~~~~~

Rationale and extra context

Current output has an extra & in the suggested fix that fails compilation.

Other cases

No response

Anything else?

No response

@tae-soo-kim tae-soo-kim added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 13, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 13, 2023
@estebank estebank self-assigned this Oct 13, 2023
@estebank estebank removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 13, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 18, 2023
…rors

Properly account for self ty in method disambiguation suggestion

Fix rust-lang#116703.
@bors bors closed this as completed in 5cc9216 Oct 18, 2023
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 T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants