Skip to content

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

@guswynn

Description

@guswynn
Contributor

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?

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Jun 2, 2021
hellow554

hellow554 commented on Jun 3, 2021

@hellow554
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

guswynn commented on Jun 3, 2021

@guswynn
ContributorAuthor

@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

hellow554 commented on Jun 3, 2021

@hellow554
Contributor

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

added
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
D-papercutDiagnostics: An error or lint that needs small tweaks.
on Jul 1, 2021
hkmatsumoto

hkmatsumoto commented on Sep 25, 2021

@hkmatsumoto
Member

@rustbot claim

added 3 commits that reference this issue on Sep 30, 2021
36bea20
6d150cd
837ac87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @hellow554@guswynn@JohnTitor@hkmatsumoto

    Issue actions

      method `xxx` is not a member of trait `XXX` doesn't check spelling · Issue #85942 · rust-lang/rust