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

method xxx is not a member of trait XXX doesn't check spelling #85942

Closed
guswynn opened this issue Jun 2, 2021 · 4 comments · Fixed by #89248
Closed

method xxx is not a member of trait XXX doesn't check spelling #85942

guswynn opened this issue Jun 2, 2021 · 4 comments · Fixed by #89248
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@guswynn
Copy link
Contributor

guswynn commented Jun 2, 2021

Today I hit this issue: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=fdce0c73a1c1190a8bd4a82c5cc24b52

but I couldn't for the life of me see the difference in the methods.

In some places, rust suggests differences that are short Levenshtein distance from each other, can that be done here as well?

@guswynn guswynn 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 Jun 2, 2021
@hellow554
Copy link
Contributor

It's done for structs and their fields/methods, but not for traits, e.g.:

struct A;
impl A {
    fn away(self) {}
}

fn main() {
    A.aay();
}
error[E0599]: no method named `aay` found for struct `A` in the current scope
  --> src/main.rs:16:7
   |
10 | struct A;
   | --------- method `aay` not found for this
...
16 |     A.aay();
   |       ^^^ help: there is an associated function with a similar name: `away`

If you would implement this for traits, there's a good chance that you might get a lof of false positives, but I can see your point, so I think this should be implemented! :)

@guswynn
Copy link
Contributor Author

guswynn commented Jun 3, 2021

@hellow554 for calling trait methods I agree, we should be careful about false-positives, but this issue is more specifically about impl-blocks for traits, where we know the exact list of required methods to implement to compare to

@hellow554
Copy link
Contributor

Ah! Yes! You're absolutely right! That's a great thing to do :D

@JohnTitor JohnTitor added C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. labels Jul 1, 2021
@hkmatsumoto
Copy link
Member

@rustbot claim

Manishearth added a commit to Manishearth/rust that referenced this issue Sep 30, 2021
…-assoc-items, r=estebank

Suggest similarly named associated items in trait impls

Fix rust-lang#85942

Previously, the compiler didn't suggest similarly named associated items unlike we do in many situations. This patch adds such diagnostics for associated functions, types, and constants.
Manishearth added a commit to Manishearth/rust that referenced this issue Sep 30, 2021
…-assoc-items, r=estebank

Suggest similarly named associated items in trait impls

Fix rust-lang#85942

Previously, the compiler didn't suggest similarly named associated items unlike we do in many situations. This patch adds such diagnostics for associated functions, types, and constants.
@bors bors closed this as completed in 837ac87 Oct 1, 2021
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. D-papercut Diagnostics: An error or lint that needs small tweaks. 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.

4 participants