-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.