Constructing struct through associated type in trait fails with E0599
Open
Nobody has claimed this yet.
A-diagnostics
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
trait T{
type A;
fn f();
}
struct S(());
impl T for (){
type A=S;
fn f(){
Self::A(());
}
}
Current output
error[E0599]: no associated item named `A` found for unit type `()` in the current scope
--> tmp.rs:12:15
|
12 | Self::A(());
| ^ associated item not found in `()`
Desired output
No response
Rationale and extra context
I am not sure if this is just a problem with the error message being wrong, or if this should actually compile.
Other cases
No response
Rust Version
rustc 1.77.2 (25ef9e3d8 2024-04-09)
binary: rustc
commit-hash: 25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04
commit-date: 2024-04-09
host: x86_64-unknown-linux-gnu
release: 1.77.2
LLVM version: 17.0.6
Anything else?
No response
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 reproducing the example in tmp.rs with rustc 1.77.2 and inspect how the compiler resolves Self::A(()). Determine whether this should compile or produce a different diagnostic; the issue is done when the expected behavior is established and the compiler handling is corrected accordingly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100