rust-lang / rust-lang/rust

Compiler hangs checking recursive LazyCell with generic lifetime

Open
#152,857 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug fixed-by-next-solver I-hang needs-triage T-compiler T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
use std::cell::LazyCell;

enum Cycle<'c, F> {
    There(Box<Cycle<'c, F>>),
    Later(Box<LazyCell<Cycle<'c, F>, F>>),
}

trait Recursive<'c>: FnOnce() -> Cycle<'c, Self> + Sized {}

impl<'c, F> Recursive<'c> for F where F: FnOnce() -> Cycle<'c, F> {}

fn recursive<'c>() -> Cycle<'c, impl Recursive<'c>> {
    let make = || Cycle::There(Box::new(recursive()));
    Cycle::Later(LazyCell::new(make))
}
Meta

rustc --version --verbose before updating:

rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: x86_64-unknown-linux-gnu
release: 1.87.0
LLVM version: 20.1.1

rustc --version --verbose after updating, yielding the same behaviour:

rustc 1.93.1 (01f6ddf75 2026-02-11)
binary: rustc
commit-hash: 01f6ddf7588f42ae2d7eb0a2f21d44e8e96674cf
commit-date: 2026-02-11
host: x86_64-unknown-linux-gnu
release: 1.93.1
LLVM version: 21.1.8
Error output

cargo check does not terminate.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the Rust reproducer with cargo check and confirm that it does not terminate. Investigate the compiler path involved in checking the recursive LazyCell and generic lifetime example; done means cargo check terminates with appropriate compiler behavior instead of 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.