Trait resolution fails, and then `rustc` hangs.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
trait Index {
type IndexRef;
}
trait Borrow {
type Borrowed<'a>;
}
trait Test {
type Ref<'a>;
type Container: Borrow where for<'a> <Self::Container as Borrow>::Borrowed<'a> : Index<IndexRef = Self::Ref<'a>>;
}
This builds fine if <Self::Container as Borrow>::Borrowed<'a> is replaced by &'a Self::Container. However, the above both errors, and also hangs rustc (still running after many minutes; wedges playground). The error is
binding for associated type
Refreferences lifetime'a, which does not appear in the trait input types
I don't understand the error, though I could imagine that it is my fault or a known limitation of GATs. However, the hanging of rustc seems likely to be a bug.
Meta
rustc --version --verbose:
rustc 1.83.0 (90b35a623 2024-11-26)
Compiler output before hang
error[E0582]: binding for associated type `IndexRef` references lifetime `'a`, which does not appear in the trait input types
--> lib.rs:11:92
|
11 | type Container: Borrow where for<'a> <Self::Container as Borrow>::Borrowed<'a> : Index<IndexRef = Self::Ref<'a>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error
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
The reproducer is shown in the issue body at lib.rs:11; first run it with rustc 1.83.0 and confirm the E0582 diagnostic and hang. Trace trait and GAT resolution for the associated-type binding, then add or update a regression test so this input terminates without hanging.
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
- Mostly clear
- Newbie friendliness
- 35/100