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

Suggestion "you might have meant to call the method with the fully-qualified path" without a call #103325

Closed
jruderman opened this issue Oct 20, 2022 · 2 comments · Fixed by #103350
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

@jruderman
Copy link
Contributor

jruderman commented Oct 20, 2022

Given the following code (playground):

trait Tr {
    fn use_mut(&mut self) {
    }
    fn oops() {
        let _ = use_mut;
    }
}
fn main() {}

The current output is:

error[E0425]: cannot find value `use_mut` in this scope
 --> src/main.rs:5:17
  |
5 |         let _ = use_mut;
  |                 ^^^^^^^
  |
help: you might have meant to call the method with the fully-qualified path
  |
5 |         let _ = Self::use_mut;
  |                 ~~~~~~~~~~~~~

It's odd for the message to say "you might have meant to call..." and then show a suggestion that does not call anything.

Possible improvements

I'm not sure which would be best:

  • When it isn't part of a call expression, change the suggestion to say "refer to the method" instead of "call the method"
  • When it isn't part of a call expression, augment the suggestion to also add parens, turning it into a call expression
  • When it isn't part of a call expression, don't show this message: the lack of parens might indicate that the programmer was trying to do something else entirely

Btw, there don't seem to be any tests that expect this message. It might be good to add one to ensure the common case (where it is a call expression) continues to have a good error message.

@jruderman jruderman 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 20, 2022
@compiler-errors
Copy link
Member

When it isn't part of a call expression, change the suggestion to say "refer to the method" instead of "call the method"

This is the best one, imo. Adding parentheses changes the program in a way that's not the responsibility of name resolution, imo.

@chenyukang
Copy link
Member

@rustbot claim

@chenyukang chenyukang removed their assignment Oct 21, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Oct 24, 2022
…=wesleywiser

Change terminology for assoc method suggestions when they are not called

Fixes rust-lang#103325

`@rustbot` label +A-diagnostics
JohnTitor pushed a commit to JohnTitor/rust that referenced this issue Oct 24, 2022
…=wesleywiser

Change terminology for assoc method suggestions when they are not called

Fixes rust-lang#103325

``@rustbot`` label +A-diagnostics
@bors bors closed this as completed in e47d222 Oct 25, 2022
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