Skip to content

ICE: thir_body queried for type_const (via cfg_attr) #151273

@Keith-Cancel

Description

@Keith-Cancel

I found this with the following code:

#![allow(incomplete_features)]
#![feature(min_generic_const_args)]

pub trait Foo {
    #[cfg_attr(feature = "some_feature", type_const)]
    const N: usize;
}

impl Foo for u32 {
    #[cfg_attr(feature = "some_feature", type_const)]
    const N: usize = 99;
}

fn main() {}

If one gets rid of the cfg_attr to just #[type_const] builds just fine. Also no issue if the feature flag is off.

Build Command:
rustc test.rs --cfg 'feature="some_feature"'

rustc-ice-2026-01-17T22_27_14-1367133.txt

@rustbot label +F-min_generic_const_args +C-bug +I-ICE +T-compiler +requires-debug-assertions

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-min_generic_const_args`#![feature(min_generic_const_args)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions