Open
Description
opened on Dec 14, 2024
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
Ref
references 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
Metadata
Assignees
Labels
Area: Associated items (types, constants & functions)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Trait systemCategory: This is a bug.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.Fixed by the next-generation trait solver, `-Znext-solver`.
Activity