-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Open
Labels
A-layoutArea: Memory layout of typesArea: Memory layout of typesA-mir-optArea: MIR optimizationsArea: MIR optimizationsA-type-systemArea: Type systemArea: Type 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.I-prioritizeIssue: Indicates that prioritization has been requested for this issue.Issue: Indicates that prioritization has been requested for this issue.S-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueT-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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
The following code causes rustc to hang when built with cargo run --release
trait Apply {
type Output<T>;
}
struct Identity;
impl Apply for Identity {
type Output<T> = T;
}
struct Thing<A: Apply>(A::Output<Self>);
/*
Effectively:
struct Thing_Identity(Thing_Identity);
*/
fn foo<A: Apply>() {
let _x: Thing<A>;
}
fn main() {
foo::<Identity>();
}Compiler output before the hang:
Compiling playground v0.0.1 (/playground)
error[E0391]: cycle detected when computing layout of `Thing<Identity>`
|
= note: ...which requires computing layout of `<Identity as Apply>::Output<Thing<Identity>>`...
= note: ...which again requires computing layout of `Thing<Identity>`, completing the cycle
note: cycle used when optimizing MIR for `main`
--> src/main.rs:20:1
|
20 | fn main() {
| ^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
See also #152885
Meta
Reproducible on the playground with version 1.95.0-nightly (2026-02-24 859951e3c7c9d0322c39)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-layoutArea: Memory layout of typesArea: Memory layout of typesA-mir-optArea: MIR optimizationsArea: MIR optimizationsA-type-systemArea: Type systemArea: Type 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.I-prioritizeIssue: Indicates that prioritization has been requested for this issue.Issue: Indicates that prioritization has been requested for this issue.S-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueT-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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.