Closed
Description
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.