-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
When a function name within a method is not found, suggest calling the method of the same name #103474
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
A similar issue: #102518, about suggesting methods when trying free functions in general, not specifically within an
Java and C# also do this. |
@rustbot claim |
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Nov 11, 2022
…tebank Suggest calling the instance method of the same name when method not found Fixes rust-lang#103474
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Nov 11, 2022
…tebank Suggest calling the instance method of the same name when method not found Fixes rust-lang#103474
Aaron1011
pushed a commit
to Aaron1011/rust
that referenced
this issue
Jan 6, 2023
…tebank Suggest calling the instance method of the same name when method not found Fixes rust-lang#103474
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.
Given the following code (playground):
The current output is:
Ideally the output should mention the fact that a method with this name was found on the same struct. And perhaps suggest calling the method on
self
, especially if the self-param types are compatible (e.g. both take an immutable&self
reference).Motivation
This may be a common error for programmers coming from C++, because C++ does not require specifying the instance for method-to-method calls.
C++ example
The text was updated successfully, but these errors were encountered: