Skip to content

[ICE]: primitive read not possible for type #154805

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(min_generic_const_args)]
#![feature(generic_const_args)]
type const ADD1<const N: usize>: usize = const { N + 1 };
type const ONE: usize = ADD1::<b"">;

original:

#![feature(min_generic_const_args)]
#![feature(generic_const_items)]
#![feature(generic_const_args)]
type const ADD1<const N: usize>: usize = const { N + 1 };
type const ONE: usize = ADD1::<b"">;
fn main() {}

Version information

rustc 1.96.0-nightly (2972b5e59 2026-04-03)
binary: rustc
commit-hash: 2972b5e59f1c5529b6ba770437812fd83ab4ebd4
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:

BackendRepr::Scalar(abi::Scalar::Initialized { .. })
| BackendRepr::ScalarPair(
abi::Scalar::Initialized { .. },
abi::Scalar::Initialized { .. }
)
) {
span_bug!(self.cur_span(), "primitive read not possible for type: {}", op.layout().ty);
}
let imm = self.read_immediate_raw(op)?.right().unwrap();
if matches!(*imm, Immediate::Uninit) {
throw_ub!(InvalidUninitBytes(None));
}
interp_ok(imm)

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

Program output

error[E0658]: generic const items are experimental
 --> /tmp/icemaker_global_tempdir.v3sG33Ug8t3x/rustc_testrunner_tmpdir_reporting.SvoBhCeWrxKl/mvce.rs:3:16
  |
3 | type const ADD1<const N: usize>: usize = const { N + 1 };
  |                ^^^^^^^^^^^^^^^^
  |
  = note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information
  = help: add `#![feature(generic_const_items)]` to the crate attributes to enable
  = note: this compiler was built on 2026-04-03; consider upgrading it if it is out of date

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.v3sG33Ug8t3x/rustc_testrunner_tmpdir_reporting.SvoBhCeWrxKl/mvce.rs:1:12
  |
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.v3sG33Ug8t3x/rustc_testrunner_tmpdir_reporting.SvoBhCeWrxKl/mvce.rs:4:37
  |
4 | type const ONE: usize = ADD1::<b"">;
  |                                     ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.v3sG33Ug8t3x/rustc_testrunner_tmpdir_reporting.SvoBhCeWrxKl/mvce.rs`

error: internal compiler error: /rustc-dev/2972b5e59f1c5529b6ba770437812fd83ab4ebd4/compiler/rustc_const_eval/src/interpret/operand.rs:679:13: primitive read not possible for type: [u8; 0]
 --> /tmp/icemaker_global_tempdir.v3sG33Ug8t3x/rustc_testrunner_tmpdir_reporting.SvoBhCeWrxKl/mvce.rs:3:50
  |
3 | type const ADD1<const N: usize>: usize = const { N + 1 };
  |                                                  ^^^^^


thread 'rustc' (3250000) panicked at /rustc-dev/2972b5e59f1c5529b6ba770437812fd83ab4ebd4/compiler/rustc_const_eval/src/interpret/operand.rs:679:13:
Box<dyn Any>
stack backtrace:
   0:     0x7effd23c0abb - <<std[de416e893de1faf9]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[9f8d6771964fc20c]::fmt::Display>::fmt
   1:     0x7effd2a1e1c8 - core[9f8d6771964fc20c]::fmt::write
   2:     0x7effd23d7ac6 - <std[de416e893de1faf9]::sys::stdio::unix::Stderr as std[de416e893de1faf9]::io::Write>::write_fmt
   3:     0x7effd2396ac8 - std[de416e893de1faf9]::panicking::default_hook::{closure#0}
   4:     0x7effd23b3ec3 - std[de416e893de1faf9]::panicking::default_hook
   5:     0x7effd13c2e4c - std[de416e893de1faf9]::panicking::update_hook::<alloc[57804382fb016052]::boxed::Box<rustc_driver_impl[7a9a631d48bc4eca]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7effd23b41a2 - std[de416e893de1faf9]::panicking::panic_with_hook
   7:     0x7effd13f2e01 - std[de416e893de1faf9]::panicking::begin_panic::<rustc_errors[e123dae814032ce5]::ExplicitBug>::{closure#0}
   8:     0x7effd13eb976 - std[de416e893de1faf9]::sys::backtrace::__rust_end_short_backtrace::<std[de416e893de1faf9]::panicking::begin_panic<rustc_errors[e123dae814032ce5]::ExplicitBug>::{closure#0}, !>
   9:     0x7effd13eb84b - std[de416e893de1faf9]::panicking::begin_panic::<rustc_errors[e123dae814032ce5]::ExplicitBug>
  10:     0x7effd13fe441 - <rustc_errors[e123dae814032ce5]::diagnostic::BugAbort as rustc_errors[e123dae814032ce5]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7effd19acbdc - <rustc_errors[e123dae814032ce5]::DiagCtxtHandle>::span_bug::<rustc_span[ae25d23050d7877d]::span_encoding::Span, alloc[57804382fb016052]::string::String>
  12:     0x7effd19d4ad6 - rustc_middle[4d5ddcd23ba200cb]::util::bug::opt_span_bug_fmt::<rustc_span[ae25d23050d7877d]::span_encoding::Span>::{closure#0}
  13:     0x7effd19d4c82 - rustc_middle[4d5ddcd23ba200cb]::ty::context::tls::with_opt::<rustc_middle[4d5ddcd23ba200cb]::util::bug::opt_span_bug_fmt<rustc_span[ae25d23050d7877d]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7effd19c523b - rustc_middle[4d5ddcd23ba200cb]::ty::context::tls::with_context_opt::<rustc_middle[4d5ddcd23ba200cb]::ty::context::tls::with_opt<rustc_middle[4d5ddcd23ba200cb]::util::bug::opt_span_bug_fmt<rustc_span[ae25d23050d7877d]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7effcfacdb18 - rustc_middle[4d5ddcd23ba200cb]::util::bug::span_bug_fmt::<rustc_span[ae25d23050d7877d]::span_encoding::Span>
  16:     0x7effd3aef530 - <rustc_const_eval[b70cca6f81c4b47b]::interpret::eval_context::InterpCx<rustc_const_eval[b70cca6f81c4b47b]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
  17:     0x7effd3aaa6df - rustc_const_eval[b70cca6f81c4b47b]::const_eval::eval_queries::eval_to_allocation_raw_provider
  18:     0x7effd3aa8ed6 - rustc_query_impl[fdd9a9cd73aeb4]::query_impl::eval_to_allocation_raw::invoke_provider_fn::__rust_begin_short_backtrace
  19:     0x7effd2e2abd3 - rustc_query_impl[fdd9a9cd73aeb4]::execution::try_execute_query::<rustc_middle[4d5ddcd23ba200cb]::query::caches::DefaultCache<rustc_middle[4d5ddcd23ba200cb]::ty::PseudoCanonicalInput<rustc_middle[4d5ddcd23ba200cb]::mir::interpret::GlobalId>, rustc_middle[4d5ddcd23ba200cb]::query::erase::ErasedData<[u8; 24usize]>>, false>
  20:     0x7effd2e2a5d1 - rustc_query_impl[fdd9a9cd73aeb4]::query_impl::eval_to_allocation_raw::execute_query_non_incr::__rust_end_short_backtrace
  21:     0x7effd30bb353 - rustc_const_eval[b70cca6f81c4b47b]::const_eval::valtrees::eval_to_valtree
  22:     0x7effd30bb126 - <rustc_const_eval[b70cca6f81c4b47b]::provide::{closure#0} as core[9f8d6771964fc20c]::ops::function::FnOnce<(rustc_middle[4d5ddcd23ba200cb]::ty::context::TyCtxt, rustc_middle[4d5ddcd23ba200cb]::ty::PseudoCanonicalInput<rustc_middle[4d5ddcd23ba200cb]::mir::interpret::GlobalId>)>>::call_once
  23:     0x7effd30bb0e2 - rustc_query_impl[fdd9a9cd73aeb4]::query_impl::eval_to_valtree::invoke_provider_fn::__rust_begin_short_backtrace
  24:     0x7effd3559426 - rustc_query_impl[fdd9a9cd73aeb4]::execution::try_execute_query::<rustc_middle[4d5ddcd23ba200cb]::query::caches::DefaultCache<rustc_middle[4d5ddcd23ba200cb]::ty::PseudoCanonicalInput<rustc_middle[4d5ddcd23ba200cb]::mir::interpret::GlobalId>, rustc_middle[4d5ddcd23ba200cb]::query::erase::ErasedData<[u8; 16usize]>>, false>
  25:     0x7effd355903e - rustc_query_impl[fdd9a9cd73aeb4]::query_impl::eval_to_valtree::execute_query_non_incr::__rust_end_short_backtrace
  26:     0x7effcfa4f1e1 - <rustc_middle[4d5ddcd23ba200cb]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
  27:     0x7effd2e04ec9 - rustc_trait_selection[68aaf85cf2f33f59]::traits::try_evaluate_const
  28:     0x7effd2e0878d - <rustc_trait_selection[68aaf85cf2f33f59]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[51f94517df34cb9f]::fold::TypeFolder<rustc_middle[4d5ddcd23ba200cb]::ty::context::TyCtxt>>::fold_const
  29:     0x7effd3e6fef7 - <rustc_trait_selection[68aaf85cf2f33f59]::traits::normalize::AssocTypeNormalizer>::normalize_free_alias::{closure#0}
  30:     0x7effd2e08d8f - <rustc_trait_selection[68aaf85cf2f33f59]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[51f94517df34cb9f]::fold::TypeFolder<rustc_middle[4d5ddcd23ba200cb]::ty::context::TyCtxt>>::fold_const
  31:     0x7effd1500b52 - <rustc_infer[eac98fb965f9dc66]::infer::at::At as rustc_trait_selection[68aaf85cf2f33f59]::traits::normalize::NormalizeExt>::normalize::<rustc_middle[4d5ddcd23ba200cb]::ty::consts::Const>
  32:     0x7effd157eef8 - rustc_hir_analysis[ffc1d045f4785174]::check::wfcheck::check_type_const
  33:     0x7effd3796cec - rustc_hir_analysis[ffc1d045f4785174]::check::check::check_item_type
  34:     0x7effd3789b9c - rustc_hir_analysis[ffc1d045f4785174]::check::wfcheck::check_well_formed
  35:     0x7effd3789b6f - rustc_query_impl[fdd9a9cd73aeb4]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  36:     0x7effd37891a4 - rustc_query_impl[fdd9a9cd73aeb4]::execution::try_execute_query::<rustc_data_structures[3e48709548f32bc4]::vec_cache::VecCache<rustc_span[ae25d23050d7877d]::def_id::LocalDefId, rustc_middle[4d5ddcd23ba200cb]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[4d5ddcd23ba200cb]::dep_graph::graph::DepNodeIndex>, false>
  37:     0x7effd3788f3b - rustc_query_impl[fdd9a9cd73aeb4]::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  38:     0x7effd37854f3 - rustc_hir_analysis[ffc1d045f4785174]::check::wfcheck::check_type_wf
  39:     0x7effd37853e7 - rustc_query_impl[fdd9a9cd73aeb4]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  40:     0x7effd3c02950 - rustc_query_impl[fdd9a9cd73aeb4]::execution::try_execute_query::<rustc_middle[4d5ddcd23ba200cb]::query::caches::SingleCache<rustc_middle[4d5ddcd23ba200cb]::query::erase::ErasedData<[u8; 1usize]>>, false>
  41:     0x7effd3c02729 - rustc_query_impl[fdd9a9cd73aeb4]::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  42:     0x7effd3306ddb - rustc_hir_analysis[ffc1d045f4785174]::check_crate
  43:     0x7effd2ab7f61 - rustc_interface[e1d24a92004beaf7]::passes::analysis
  44:     0x7effd3c05049 - rustc_query_impl[fdd9a9cd73aeb4]::execution::try_execute_query::<rustc_middle[4d5ddcd23ba200cb]::query::caches::SingleCache<rustc_middle[4d5ddcd23ba200cb]::query::erase::ErasedData<[u8; 0usize]>>, false>
  45:     0x7effd3c04cb5 - rustc_query_impl[fdd9a9cd73aeb4]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  46:     0x7effd3bb1990 - rustc_interface[e1d24a92004beaf7]::interface::run_compiler::<(), rustc_driver_impl[7a9a631d48bc4eca]::run_compiler::{closure#0}>::{closure#1}
  47:     0x7effd3be3c3e - std[de416e893de1faf9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e1d24a92004beaf7]::util::run_in_thread_with_globals<rustc_interface[e1d24a92004beaf7]::util::run_in_thread_pool_with_globals<rustc_interface[e1d24a92004beaf7]::interface::run_compiler<(), rustc_driver_impl[7a9a631d48bc4eca]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  48:     0x7effd3be44e0 - <std[de416e893de1faf9]::thread::lifecycle::spawn_unchecked<rustc_interface[e1d24a92004beaf7]::util::run_in_thread_with_globals<rustc_interface[e1d24a92004beaf7]::util::run_in_thread_pool_with_globals<rustc_interface[e1d24a92004beaf7]::interface::run_compiler<(), rustc_driver_impl[7a9a631d48bc4eca]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9f8d6771964fc20c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7effd3be53ec - <std[de416e893de1faf9]::sys::thread::unix::Thread>::new::thread_start
  50:     0x7effcd6a597a - <unknown>
  51:     0x7effcd7292bc - <unknown>
  52:                0x0 - <unknown>

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 (2972b5e59 2026-04-03) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `ADD1::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
#2 [check_well_formed] checking that `ONE` is well-formed
#3 [check_type_wf] checking that types are well-formed
#4 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.

@rustbot label +F-min_generic_const_args +F-generic_const_items +F-generic_const_args

Metadata

Metadata

Assignees

No one assigned

    Labels

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