Skip to content

Compiler hang: infinite type expansion for trait impl with recursive double-reference bound (&'a &'a T) #151961

Description

@elimayano

I encountered a compiler hang when compiling a code snippet with a recursive trait implementation involving double references.

Instead of hitting the recursion_limit or reporting a conflicting implementation error, the compiler continues to consume memory. Maybe related to #151632

trait UseRef {}
impl<T> UseRef for T {}
impl<'a, T> UseRef for & T
where
    T: UseRef,
    &'a &'a T: UseRef,
{}
fn main(){}

Meta

rustc --version --verbose:

rustc 1.93.0 (254b59607 2026-01-19)
binary: rustc
commit-hash: 254b59607d4417e9dffbc307138ae5c86280fe4c
commit-date: 2026-01-19
host: x86_64-unknown-linux-gnu
release: 1.93.0
LLVM version: 21.1.8
Backtrace

<backtrace>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-coherenceArea: CoherenceC-bugCategory: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant 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.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions