-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Open
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.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.T-typesRelevant to the types 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-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.
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
lqd
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.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.T-typesRelevant to the types 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-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.