Closed
Description
Consider this example:
struct GenericAssocMethod<T>(T);
impl<T> GenericAssocMethod<T> {
fn default_hello() {}
}
fn main() {
let x = GenericAssocMethod(33i32);
x.default_hello();
}
This errors with the following error:
error[E0599]: no method named `default_hello` found for type `GenericAssocMethod<i32>` in the current scope
--> src/main.rs:8:7
|
1 | struct GenericAssocMethod<T>(T);
| -------------------------------- method `default_hello` not found for this
...
8 | x.default_hello();
| --^^^^^^^^^^^^^
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `GenericAssocMethod<i32>::default_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 `GenericAssocMethod<_>`
--> src/main.rs:3:5
|
3 | fn default_hello() {}
| ^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
The problem is that if I follow the hint exactly, I end up with GenericAssocMethod<i32>::default_hello();
, which is invalid rust syntax.
Ideally, I believe suggesting GenericAssocMethod::<i32>::default_hello
would be more beneficial.
Submitting this and #61411 as two separate issues, but I found both for the same hint.