rust-lang / rust-lang/rust

Compiler hang due to field-representing types defining a struct in terms of itself.

Open
#153,256 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-field_projections I-hang T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

The following code causes rustc to hang, instead of emitting a normal compiler error:

#![feature(field_projections)]
#![expect(incomplete_features)]

use std::field::{Field, field_of};

pub struct Weird<T>(<field_of!(Weird<Option<T>>, 0) as Field>::Type);
Meta

rustc --version --verbose:

rustc 1.96.0-nightly (38c0de8dc 2026-02-28)
binary: rustc
commit-hash: 38c0de8dcb14d42290042521be9958d37f3fa390
commit-date: 2026-02-28
host: x86_64-pc-windows-msvc
release: 1.96.0-nightly
LLVM version: 22.1.0

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 provided minimal Rust program with the reported nightly rustc version and confirm that it hangs. Trace the compiler handling of field_projections and the recursive field-representing type; done means rustc terminates and emits a normal compiler error for this input.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.