Skip to content

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

Closed
@jruderman

Description

@jruderman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-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

    No branches or pull requests

    Issue actions