Skip to content

ICE: abi: index out of bounds (offsets[FieldIdx::new(i)]) #150714

@matthiaskrgr

Description

@matthiaskrgr

snippet:

#![feature(min_generic_const_args, adt_const_params)]
use std::marker::ConstParamTy;
#[derive(Eq, PartialEq, ConstParamTy)]
struct Inner(u32);
#[derive(Eq, PartialEq, ConstParamTy)]
enum Container<T> {
    Wrap(T),
}
fn with_container<const C: Container<Inner>>() -> Container<Inner> {
    C
}
fn test<const N: u32>() {
    with_container::<{ Container::Wrap::<Inner>(<Option<u32>>::Some(const { 2 })) }>();
}
fn main() {
    test::<5>()
}

Version information

rustc 1.94.0-nightly (bd33b83cf 2026-01-05)
binary: rustc
commit-hash: bd33b83cfdbac9bffa3b04aaef95ec97827909a9
commit-date: 2026-01-05
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8

Possibly related line of code:

}
FieldsShape::Array { stride, count } => {
let i = u64::try_from(i).unwrap();
assert!(i < count, "tried to access field {i} of array with {count} fields");
stride * i
}
FieldsShape::Arbitrary { ref offsets, .. } => offsets[FieldIdx::new(i)],
}
}
/// Gets source indices of the fields by increasing offsets.
#[inline]
pub fn index_by_increasing_offset(&self) -> impl ExactSizeIterator<Item = usize> {

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

Program output

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.0zyhRWa0bgY0/rustc_testrunner_tmpdir_reporting.ktlScgbeV7Bs/mvce.rs:1:12
  |
1 | #![feature(min_generic_const_args, adt_const_params)]
  |            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
  = note: `#[warn(incomplete_features)]` on by default


thread 'rustc' (1885864) panicked at /rustc-dev/bd33b83cfdbac9bffa3b04aaef95ec97827909a9/compiler/rustc_abi/src/lib.rs:1676:66:
index out of bounds: the len is 1 but the index is 1
stack backtrace:
   0:     0x7f00c8020fc3 - <<std[6810ad95c09a1f38]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[8c39a0108b8da36b]::fmt::Display>::fmt
   1:     0x7f00c860e348 - core[8c39a0108b8da36b]::fmt::write
   2:     0x7f00c8037246 - <std[6810ad95c09a1f38]::sys::stdio::unix::Stderr as std[6810ad95c09a1f38]::io::Write>::write_fmt
   3:     0x7f00c7ff6df8 - std[6810ad95c09a1f38]::panicking::default_hook::{closure#0}
   4:     0x7f00c8014853 - std[6810ad95c09a1f38]::panicking::default_hook
   5:     0x7f00c6ffb1da - std[6810ad95c09a1f38]::panicking::update_hook::<alloc[c78df5de1e68b592]::boxed::Box<rustc_driver_impl[4e21432d7c76ef67]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f00c8014b32 - std[6810ad95c09a1f38]::panicking::panic_with_hook
   7:     0x7f00c7ff6eb8 - std[6810ad95c09a1f38]::panicking::panic_handler::{closure#0}
   8:     0x7f00c7fedb79 - std[6810ad95c09a1f38]::sys::backtrace::__rust_end_short_backtrace::<std[6810ad95c09a1f38]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f00c7ff898d - __rustc[a475064d16802d7f]::rust_begin_unwind
  10:     0x7f00c5158fec - core[8c39a0108b8da36b]::panicking::panic_fmt
  11:     0x7f00c4ffa553 - core[8c39a0108b8da36b]::panicking::panic_bounds_check
  12:     0x7f00ca4094cd - <rustc_const_eval[6fc806a0c4979697]::interpret::eval_context::InterpCx<rustc_const_eval[6fc806a0c4979697]::const_eval::machine::CompileTimeMachine>>::project_field::<rustc_const_eval[6fc806a0c4979697]::interpret::place::MPlaceTy>.cold
  13:     0x7f00c8b2fbda - rustc_const_eval[6fc806a0c4979697]::const_eval::valtrees::valtree_into_mplace
  14:     0x7f00c8b2f90e - rustc_const_eval[6fc806a0c4979697]::const_eval::valtrees::valtree_into_mplace
  15:     0x7f00c96f295c - rustc_const_eval[6fc806a0c4979697]::const_eval::valtrees::valtree_to_const_value
  16:     0x7f00c96f232b - <rustc_const_eval[6fc806a0c4979697]::provide::{closure#1} as core[8c39a0108b8da36b]::ops::function::FnOnce<(rustc_middle[42237da0a4c7601]::ty::context::TyCtxt, rustc_middle[42237da0a4c7601]::ty::consts::valtree::Value)>>::call_once
  17:     0x7f00c96f22d6 - rustc_query_impl[4d93b3b10c7f5167]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4d93b3b10c7f5167]::query_impl::valtree_to_const_val::dynamic_query::{closure#2}::{closure#0}, rustc_middle[42237da0a4c7601]::query::erase::Erased<[u8; 24usize]>>
  18:     0x7f00c96f229f - <rustc_query_impl[4d93b3b10c7f5167]::query_impl::valtree_to_const_val::dynamic_query::{closure#2} as core[8c39a0108b8da36b]::ops::function::FnOnce<(rustc_middle[42237da0a4c7601]::ty::context::TyCtxt, rustc_middle[42237da0a4c7601]::ty::consts::valtree::Value)>>::call_once
  19:     0x7f00c96f18cc - rustc_query_system[747dc01c13837c3b]::query::plumbing::try_execute_query::<rustc_query_impl[4d93b3b10c7f5167]::DynamicConfig<rustc_query_system[747dc01c13837c3b]::query::caches::DefaultCache<rustc_middle[42237da0a4c7601]::ty::consts::valtree::Value, rustc_middle[42237da0a4c7601]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[4d93b3b10c7f5167]::plumbing::QueryCtxt, false>
  20:     0x7f00c96f15e5 - rustc_query_impl[4d93b3b10c7f5167]::query_impl::valtree_to_const_val::get_query_non_incr::__rust_end_short_backtrace
  21:     0x7f00c90aed87 - rustc_monomorphize[df187732e26b04b8]::collector::items_of_instance
  22:     0x7f00c90aaff2 - rustc_query_impl[4d93b3b10c7f5167]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4d93b3b10c7f5167]::query_impl::items_of_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[42237da0a4c7601]::query::erase::Erased<[u8; 32usize]>>
  23:     0x7f00c92c0b95 - rustc_query_system[747dc01c13837c3b]::query::plumbing::try_execute_query::<rustc_query_impl[4d93b3b10c7f5167]::DynamicConfig<rustc_query_system[747dc01c13837c3b]::query::caches::DefaultCache<(rustc_middle[42237da0a4c7601]::ty::instance::Instance, rustc_middle[42237da0a4c7601]::mir::mono::CollectionMode), rustc_middle[42237da0a4c7601]::query::erase::Erased<[u8; 32usize]>>, false, false, false>, rustc_query_impl[4d93b3b10c7f5167]::plumbing::QueryCtxt, false>
  24:     0x7f00c92c07b3 - rustc_query_impl[4d93b3b10c7f5167]::query_impl::items_of_instance::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7f00c9adaf54 - rustc_monomorphize[df187732e26b04b8]::collector::collect_items_rec
  26:     0x7f00c9adcea7 - rustc_monomorphize[df187732e26b04b8]::collector::collect_items_rec
  27:     0x7f00c9adcea7 - rustc_monomorphize[df187732e26b04b8]::collector::collect_items_rec
  28:     0x7f00c8abb3ed - rustc_monomorphize[df187732e26b04b8]::collector::collect_crate_mono_items::{closure#1}::{closure#0}
  29:     0x7f00c8e822ba - rustc_monomorphize[df187732e26b04b8]::partitioning::collect_and_partition_mono_items
  30:     0x7f00c9a28764 - rustc_query_impl[4d93b3b10c7f5167]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4d93b3b10c7f5167]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[42237da0a4c7601]::query::erase::Erased<[u8; 24usize]>>
  31:     0x7f00c9a28749 - <rustc_query_impl[4d93b3b10c7f5167]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[8c39a0108b8da36b]::ops::function::FnOnce<(rustc_middle[42237da0a4c7601]::ty::context::TyCtxt, ())>>::call_once
  32:     0x7f00c9a2829e - rustc_query_system[747dc01c13837c3b]::query::plumbing::try_execute_query::<rustc_query_impl[4d93b3b10c7f5167]::DynamicConfig<rustc_query_system[747dc01c13837c3b]::query::caches::SingleCache<rustc_middle[42237da0a4c7601]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[4d93b3b10c7f5167]::plumbing::QueryCtxt, false>
  33:     0x7f00c9a28043 - rustc_query_impl[4d93b3b10c7f5167]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7f00c9a2fa20 - rustc_codegen_ssa[e1295ddd32952513]::base::codegen_crate::<rustc_codegen_llvm[443ddb3aab83af46]::LlvmCodegenBackend>
  35:     0x7f00c9a2d4fd - <rustc_codegen_llvm[443ddb3aab83af46]::LlvmCodegenBackend as rustc_codegen_ssa[e1295ddd32952513]::traits::backend::CodegenBackend>::codegen_crate
  36:     0x7f00c996b40f - <rustc_interface[5d1daf306103d6d4]::queries::Linker>::codegen_and_build_linker
  37:     0x7f00c9968a1c - <rustc_interface[5d1daf306103d6d4]::passes::create_and_enter_global_ctxt<core[8c39a0108b8da36b]::option::Option<rustc_interface[5d1daf306103d6d4]::queries::Linker>, rustc_driver_impl[4e21432d7c76ef67]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[8c39a0108b8da36b]::ops::function::FnOnce<(&rustc_session[b55a0c80c17f87]::session::Session, rustc_middle[42237da0a4c7601]::ty::context::CurrentGcx, alloc[c78df5de1e68b592]::sync::Arc<rustc_data_structures[b6e1d723e783a0f9]::jobserver::Proxy>, &std[6810ad95c09a1f38]::sync::once_lock::OnceLock<rustc_middle[42237da0a4c7601]::ty::context::GlobalCtxt>, &rustc_data_structures[b6e1d723e783a0f9]::sync::worker_local::WorkerLocal<rustc_middle[42237da0a4c7601]::arena::Arena>, &rustc_data_structures[b6e1d723e783a0f9]::sync::worker_local::WorkerLocal<rustc_hir[570d9ac2d5177df8]::Arena>, rustc_driver_impl[4e21432d7c76ef67]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  38:     0x7f00c98140d8 - rustc_interface[5d1daf306103d6d4]::interface::run_compiler::<(), rustc_driver_impl[4e21432d7c76ef67]::run_compiler::{closure#0}>::{closure#1}
  39:     0x7f00c978cbce - std[6810ad95c09a1f38]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5d1daf306103d6d4]::util::run_in_thread_with_globals<rustc_interface[5d1daf306103d6d4]::util::run_in_thread_pool_with_globals<rustc_interface[5d1daf306103d6d4]::interface::run_compiler<(), rustc_driver_impl[4e21432d7c76ef67]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  40:     0x7f00c978c9a0 - <std[6810ad95c09a1f38]::thread::lifecycle::spawn_unchecked<rustc_interface[5d1daf306103d6d4]::util::run_in_thread_with_globals<rustc_interface[5d1daf306103d6d4]::util::run_in_thread_pool_with_globals<rustc_interface[5d1daf306103d6d4]::interface::run_compiler<(), rustc_driver_impl[4e21432d7c76ef67]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[8c39a0108b8da36b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x7f00c978e744 - <std[6810ad95c09a1f38]::sys::thread::unix::Thread>::new::thread_start
  42:     0x7f00c309698b - <unknown>
  43:     0x7f00c311a9cc - <unknown>
  44:                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.94.0-nightly (bd33b83cf 2026-01-05) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [valtree_to_const_val] converting type-level constant value to MIR constant value
#1 [items_of_instance] collecting items used by `with_container::<ValTree(Branch([ValTree(Leaf(0x00000000): u32), ValTree(Branch([ValTree(Leaf(0x00000001): u32), ValTree(Leaf(0x00000002): u32)]): core::option::Option::<u32>)]): Container<Inner>)>`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
warning: 1 warning emitted


@rustbot label +F-min_generic_const_args +F-adt_const_params

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-adt_const_params`#![feature(adt_const_params)]`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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions