Hint for E0790 does not result in valid code (missing path to implementation)
Open
Nobody has claimed this yet.
A-diagnostics
A-suggestion-diagnostics
D-invalid-suggestion
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
mod base {
pub trait T {
fn f();
}
pub struct S;
impl T for S {
fn f() {}
}
}
pub fn foo() {
base::T::f();
}
fn main() { }
Current output
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
--> awex.rs:14:5
|
3 | fn f();
| ------- `T::f` defined here
...
14 | base::T::f();
| ^^^^^^^^^^ cannot call associated function of trait
|
help: use the fully-qualified path to the only available implementation
|
14 | <S as base::T>::f();
| +++++ +
Desired output
help: use the fully-qualified path to the only available implementation
|
14 | <base::S as base::T>::f();
| +++++++++++ +
Rationale and extra context
Since base::S has not been imported, the hint code should use base::S rather than S
Other cases
No response
Anything else?
I noticed this in tests/ui/traits/static-method-generic-inference.rs. Reduced to isolate the issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading and running tests/ui/traits/static-method-generic-inference.rs, then compare the E0790 diagnostic with the reduced example in this issue. Done means the hint uses the fully qualified path <base::S as base::T>::f() when the implementation type is not imported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100