Skip to content

[ICE]: attempting to project to field at offset 0 with size 8 into immediate with layout TyAndLayout #154750

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(, min_generic_const_args, )]

type const CONST: usize = 1u32;

fn uses_const() {
    CONST;
}

original:

//@ check-pass
// This test should compile without an ICE.
#![expect(incomplete_features)]
#![feature(adt_const_params, min_generic_const_args, generic_const_parameter_types)]

type const CONST: usize = 1u32;

fn uses_const() {
    CONST;
}

fn main(_x: T) {}

Version information

rustc 1.96.0-nightly (5bbdeaa9a 2026-04-03)
binary: rustc
commit-hash: 5bbdeaa9a8dc563185f40e99f96704cbcc7a6e6e
commit-date: 2026-04-03
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.2

Possibly related line of code:

cx,
);
}
// `ImmTy` have already been checked to be in-bounds, so we can just check directly if this
// remains in-bounds. This cannot actually be violated since projections are type-checked
// and bounds-checked.
assert!(
offset + layout.size <= self.layout.size,
"attempting to project to field at offset {} with size {} into immediate with layout {:#?}",
offset.bytes(),
layout.size.bytes(),
self.layout,
);

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: expected identifier, found `,`
 --> /tmp/icemaker_global_tempdir.v6JAMnE8yYt0/rustc_testrunner_tmpdir_reporting.RsHGpw3AHJUJ/mvce.rs:1:12
  |
1 | #![feature(, min_generic_const_args, )]
  |            ^ expected identifier
  |
help: remove this comma
  |
1 - #![feature(, min_generic_const_args, )]
1 + #![feature( min_generic_const_args, )]
  |

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.v6JAMnE8yYt0/rustc_testrunner_tmpdir_reporting.RsHGpw3AHJUJ/mvce.rs:1:14
  |
1 | #![feature(, min_generic_const_args, )]
  |              ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.v6JAMnE8yYt0/rustc_testrunner_tmpdir_reporting.RsHGpw3AHJUJ/mvce.rs:7:2
  |
7 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.v6JAMnE8yYt0/rustc_testrunner_tmpdir_reporting.RsHGpw3AHJUJ/mvce.rs`

error: the constant `1` is not of type `usize`
 --> /tmp/icemaker_global_tempdir.v6JAMnE8yYt0/rustc_testrunner_tmpdir_reporting.RsHGpw3AHJUJ/mvce.rs:3:1
  |
3 | type const CONST: usize = 1u32;
  | ^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `u32`


thread 'rustc' (966057) panicked at /rustc-dev/5bbdeaa9a8dc563185f40e99f96704cbcc7a6e6e/compiler/rustc_const_eval/src/interpret/operand.rs:388:9:
attempting to project to field at offset 0 with size 8 into immediate with layout TyAndLayout {
    ty: u32,
    layout: Layout {
        size: Size(4 bytes),
        align: AbiAlign {
            abi: Align(4 bytes),
        },
        backend_repr: Scalar(
            Initialized {
                value: Int(
                    I32,
                    false,
                ),
                valid_range: 0..=4294967295,
            },
        ),
        fields: Primitive,
        largest_niche: None,
        uninhabited: false,
        variants: Single {
            index: 0,
        },
        max_repr_align: None,
        unadjusted_abi_align: Align(4 bytes),
        randomization_seed: 18446462607322841091,
    },
}
stack backtrace:
   0:     0x7f09ef1c8d7b - <<std[55fbeb01ec93ae41]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[6b09cf77c14f6d64]::fmt::Display>::fmt
   1:     0x7f09ef81db88 - core[6b09cf77c14f6d64]::fmt::write
   2:     0x7f09ef1dfd86 - <std[55fbeb01ec93ae41]::sys::stdio::unix::Stderr as std[55fbeb01ec93ae41]::io::Write>::write_fmt
   3:     0x7f09ef19ed88 - std[55fbeb01ec93ae41]::panicking::default_hook::{closure#0}
   4:     0x7f09ef1bc183 - std[55fbeb01ec93ae41]::panicking::default_hook
   5:     0x7f09ee1c00bc - std[55fbeb01ec93ae41]::panicking::update_hook::<alloc[371bb832da918502]::boxed::Box<rustc_driver_impl[948c84815bc57e07]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f09ef1bc462 - std[55fbeb01ec93ae41]::panicking::panic_with_hook
   7:     0x7f09ef19ee48 - std[55fbeb01ec93ae41]::panicking::panic_handler::{closure#0}
   8:     0x7f09ef193399 - std[55fbeb01ec93ae41]::sys::backtrace::__rust_end_short_backtrace::<std[55fbeb01ec93ae41]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f09ef1a08ad - __rustc[f516f04310ac789b]::rust_begin_unwind
  10:     0x7f09ebca6a8c - core[6b09cf77c14f6d64]::panicking::panic_fmt
  11:     0x7f09f163d2ba - <rustc_const_eval[943d02374ec5aa24]::interpret::operand::ImmTy>::offset_::<rustc_const_eval[943d02374ec5aa24]::interpret::eval_context::InterpCx<rustc_const_eval[943d02374ec5aa24]::const_eval::dummy_machine::DummyMachine>>.cold
  12:     0x7f09f0036d65 - <rustc_mir_transform[821c4539e524a24d]::known_panics_lint::ConstPropagator as rustc_middle[39fdeca766187dd]::mir::visit::Visitor>::visit_assign
  13:     0x7f09f0030bc0 - <rustc_mir_transform[821c4539e524a24d]::known_panics_lint::ConstPropagator as rustc_middle[39fdeca766187dd]::mir::visit::Visitor>::visit_body
  14:     0x7f09f002de8f - <rustc_mir_transform[821c4539e524a24d]::known_panics_lint::KnownPanicsLint as rustc_mir_transform[821c4539e524a24d]::pass_manager::MirLint>::run_lint
  15:     0x7f09ef80d03c - rustc_mir_transform[821c4539e524a24d]::run_analysis_to_runtime_passes
  16:     0x7f09f04c56b7 - rustc_mir_transform[821c4539e524a24d]::mir_drops_elaborated_and_const_checked
  17:     0x7f09f04c5159 - rustc_query_impl[2232f359ced67f13]::query_impl::mir_drops_elaborated_and_const_checked::invoke_provider_fn::__rust_begin_short_backtrace
  18:     0x7f09ef8b9f26 - rustc_query_impl[2232f359ced67f13]::execution::try_execute_query::<rustc_data_structures[4cf2110bba7d42f2]::vec_cache::VecCache<rustc_span[a1f4f8c3615135ef]::def_id::LocalDefId, rustc_middle[39fdeca766187dd]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[39fdeca766187dd]::dep_graph::graph::DepNodeIndex>, false>
  19:     0x7f09ef8b7555 - rustc_query_impl[2232f359ced67f13]::query_impl::mir_drops_elaborated_and_const_checked::execute_query_non_incr::__rust_end_short_backtrace
  20:     0x7f09ef8b7988 - <rustc_middle[39fdeca766187dd]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[2f488dcf8b7ae4e4]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  21:     0x7f09ef8b6ac2 - rustc_interface[2f488dcf8b7ae4e4]::passes::analysis
  22:     0x7f09f0a2e849 - rustc_query_impl[2232f359ced67f13]::execution::try_execute_query::<rustc_middle[39fdeca766187dd]::query::caches::SingleCache<rustc_middle[39fdeca766187dd]::query::erase::ErasedData<[u8; 0usize]>>, false>
  23:     0x7f09f0a2e529 - rustc_query_impl[2232f359ced67f13]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7f09f0a01194 - rustc_interface[2f488dcf8b7ae4e4]::interface::run_compiler::<(), rustc_driver_impl[948c84815bc57e07]::run_compiler::{closure#0}>::{closure#1}
  25:     0x7f09f09dbc3e - std[55fbeb01ec93ae41]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[2f488dcf8b7ae4e4]::util::run_in_thread_with_globals<rustc_interface[2f488dcf8b7ae4e4]::util::run_in_thread_pool_with_globals<rustc_interface[2f488dcf8b7ae4e4]::interface::run_compiler<(), rustc_driver_impl[948c84815bc57e07]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  26:     0x7f09f09dc4e0 - <std[55fbeb01ec93ae41]::thread::lifecycle::spawn_unchecked<rustc_interface[2f488dcf8b7ae4e4]::util::run_in_thread_with_globals<rustc_interface[2f488dcf8b7ae4e4]::util::run_in_thread_pool_with_globals<rustc_interface[2f488dcf8b7ae4e4]::interface::run_compiler<(), rustc_driver_impl[948c84815bc57e07]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[6b09cf77c14f6d64]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x7f09f09dd36c - <std[55fbeb01ec93ae41]::sys::thread::unix::Thread>::new::thread_start
  28:     0x7f09ea4a597a - <unknown>
  29:     0x7f09ea5292bc - <unknown>
  30:                0x0 - <unknown>

error: the compiler unexpectedly panicked. This is a bug

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.96.0-nightly (5bbdeaa9a 2026-04-03) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `uses_const`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0601`.

@rustbot label +F-min_generic_const_args

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.

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