Closed
Description
Code
struct A {}
impl A {
fn hello(a: i32) {}
}
fn main() {
let a = A {};
a.hello(1);
}
Current output
error[E0599]: no method named `hello` found for struct `A` in the current scope
--> src/main.rs:46:7
|
38 | struct A {}
| -------- method `hello` not found for this struct
...
46 | a.hello(1);
| --^^^^^---
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `A::hello(a, 1)`
|
= 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 `A`
--> src/main.rs:41:5
|
41 | fn hello(a: i32) {}
| ^^^^^^^^^^^^^^^^
Desired output
receiver shouldn't be treated as the first arg of the assoc function when the first arg of the assoc function isn't the same as the current impl type
46 | a.hello(1);
| --^^^^^---
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `A::hello(1)`
Rationale and extra context
rustc --version
rustc 1.75.0-nightly (9d83ac2 2023-10-31)
Other cases
no
Anything else?
no