You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect hint when calling associated method as method with Deref #61411
A-associated-itemsArea: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.
use std::cell::RefCell;structHasAssocMethod;implHasAssocMethod{fnhello(){}}fnmain(){let shared_state = RefCell::new(HasAssocMethod);let state = shared_state.borrow_mut();
state.hello();}
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.
A-associated-itemsArea: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.
Activity
Rollup merge of rust-lang#65145 - estebank:turbofish-assoc-fn-call, r…
Rollup merge of rust-lang#65145 - estebank:turbofish-assoc-fn-call, r…