Closed
Description
Here's a simple example:
use std::cell::RefCell;
struct HasAssocMethod;
impl HasAssocMethod {
fn hello() {}
}
fn main() {
let shared_state = RefCell::new(HasAssocMethod);
let state = shared_state.borrow_mut();
state.hello();
}
This outputs the following error:
Compiling playground v0.0.1 (/playground)
error[E0599]: no method named `hello` found for type `std::cell::RefMut<'_, HasAssocMethod>` in the current scope
--> src/main.rs:13:11
|
13 | state.hello();
| ------^^^^^
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `std::cell::RefMut<'_, HasAssocMethod>::hello`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `HasAssocMethod`
--> src/main.rs:6:5
|
6 | fn hello() {}
| ^^^^^^^^^^
error: aborting due to previous error
The hint is incorrect, as std::cell::RefMut<'_, HasAssocMethod>::hello();
does not exist. Ideally the compiler should suggest HasAssocMethod::hello();
.
Submitting this and #61412 as two separate issues, but I found both for the same hint.