Closed
Description
Given the following code:
trait TraitA<T> {
fn func();
}
struct StructA {}
impl TraitA<i32> for StructA {
fn func() {}
}
fn main() {
TraitA::<i32>::func();
}
The current output is:
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
--> src/main.rs:12:5
|
2 | fn func();
| ---------- `TraitA::func` defined here
...
12 | TraitA::<i32>::func();
| ^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait
|
help: use the fully-qualified path to the only available implementation
|
12 | <::StructA as TraitA>::<i32>::func();
| +++++++++++++ +
error: aborting due to previous error
For more information about this error, try `rustc --explain E0790`.
Ideally the output should look like:
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
--> src/main.rs:12:5
|
2 | fn func();
| ---------- `TraitA::func` defined here
...
12 | TraitA::<i32>::func();
| ^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait
|
help: use the fully-qualified path to the only available implementation
|
12 | <StructA as TraitA<i32>>::func();
| ++++++++++++ +
error: aborting due to previous error
For more information about this error, try `rustc --explain E0790`.
The suggested code when trying to call associated function on trait without specifying the corresponding impl
type does not compile, as the type parameter is in the wrong place.