Skip to content

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

@theemathas

Description

@theemathas

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-field_projections`#![feature(field_projections)]`I-hangIssue: 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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions