Skip to content

[ICE]: invalid immediate for given destination place: value ScalarPair( .. ) #159572

Description

@matthiaskrgr

Code

trait A {
    fn foo(&self) -> Self
    where
        Self: Copy;
}
impl A for [&()] {
    fn foo(&self) -> Self
    where
        Self: Copy,
    {
        *(&[] as &_)
    }
}
fn main() {}

Meta

rustc --version --verbose:

rustc 1.99.0-nightly (eff8269f7 2026-07-18)
binary: rustc
commit-hash: eff8269f797067c30555e77f160ec84c0ed15cd9
commit-date: 2026-07-18
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8

Error output

warning: this item cannot be used as its where bounds are not satisfied for the `Self` type
 --> a.rs:7:5
  |
7 | /     fn foo(&self) -> Self
8 | |     where
9 | |         Self: Copy,
  | |___________________^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: trait `A` is never used
 --> a.rs:1:7
  |
1 | trait A {
  |       ^
Backtrace

error: internal compiler error: /rustc-dev/eff8269f797067c30555e77f160ec84c0ed15cd9/compiler/rustc_const_eval/src/interpret/operand.rs:163:17: invalid immediate for given destination place: value ScalarPair(alloc2<imm>, 0x0000000000000000) does not match ABI Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }))


thread 'rustc' (1478009) panicked at /rustc-dev/eff8269f797067c30555e77f160ec84c0ed15cd9/compiler/rustc_const_eval/src/interpret/operand.rs:163:17:
Box<dyn Any>
stack backtrace:
   0:     0x7fb02d450a16 - <<std[2a8c3cd46992084f]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[f0447a45d83adb47]::fmt::Display>::fmt
   1:     0x7fb02da0ec88 - core[f0447a45d83adb47]::fmt::write
   2:     0x7fb02d465c7c - <std[2a8c3cd46992084f]::sys::stdio::unix::Stderr as core[f0447a45d83adb47]::io::write::Write>::write_fmt
   3:     0x7fb02d4226aa - std[2a8c3cd46992084f]::panicking::default_hook::{closure#0}
   4:     0x7fb02d443143 - std[2a8c3cd46992084f]::panicking::default_hook
   5:     0x7fb02c3fc04b - std[2a8c3cd46992084f]::panicking::update_hook::<alloc[4a894a599ddd1b2d]::boxed::Box<rustc_driver_impl[c2a64f8504684822]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fb02d4435e2 - std[2a8c3cd46992084f]::panicking::panic_with_hook
   7:     0x7fb02c429b01 - std[2a8c3cd46992084f]::panicking::begin_panic::<rustc_errors[1361c60ac6b93a37]::ExplicitBug>::{closure#0}
   8:     0x7fb02c4229e6 - std[2a8c3cd46992084f]::sys::backtrace::__rust_end_short_backtrace::<std[2a8c3cd46992084f]::panicking::begin_panic<rustc_errors[1361c60ac6b93a37]::ExplicitBug>::{closure#0}, !>
   9:     0x7fb02c4208b7 - std[2a8c3cd46992084f]::panicking::begin_panic::<rustc_errors[1361c60ac6b93a37]::ExplicitBug>
  10:     0x7fb02c434c91 - <rustc_errors[1361c60ac6b93a37]::diagnostic::BugAbort as rustc_errors[1361c60ac6b93a37]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fb02c9c19e9 - rustc_middle[96c442875f2cb62c]::util::bug::opt_span_bug_fmt::<rustc_span[157f53c51de8f998]::span_encoding::Span>::{closure#0}
  12:     0x7fb02c9c1b52 - rustc_middle[96c442875f2cb62c]::ty::context::tls::with_opt::<rustc_middle[96c442875f2cb62c]::util::bug::opt_span_bug_fmt<rustc_span[157f53c51de8f998]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7fb02c9ace0b - rustc_middle[96c442875f2cb62c]::ty::context::tls::with_context_opt::<rustc_middle[96c442875f2cb62c]::ty::context::tls::with_opt<rustc_middle[96c442875f2cb62c]::util::bug::opt_span_bug_fmt<rustc_span[157f53c51de8f998]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7fb029ee23d4 - rustc_middle[96c442875f2cb62c]::util::bug::bug_fmt
  15:     0x7fb02f818f1f - <rustc_const_eval[d2342b225955019d]::interpret::operand::Immediate>::assert_matches_abi::<rustc_const_eval[d2342b225955019d]::interpret::eval_context::InterpCx<rustc_const_eval[d2342b225955019d]::const_eval::dummy_machine::DummyMachine>>.cold
  16:     0x7fb02e7231cf - <rustc_const_eval[d2342b225955019d]::interpret::eval_context::InterpCx<rustc_const_eval[d2342b225955019d]::const_eval::dummy_machine::DummyMachine>>::write_immediate_to_mplace_no_validate
  17:     0x7fb02e72c5b9 - <rustc_const_eval[d2342b225955019d]::interpret::eval_context::InterpCx<rustc_const_eval[d2342b225955019d]::const_eval::dummy_machine::DummyMachine>>::write_immediate_no_validate::<rustc_const_eval[d2342b225955019d]::interpret::place::MPlaceTy>
  18:     0x7fb02e72c406 - <rustc_const_eval[d2342b225955019d]::interpret::eval_context::InterpCx<rustc_const_eval[d2342b225955019d]::const_eval::dummy_machine::DummyMachine>>::unsize_into_ptr::<rustc_const_eval[d2342b225955019d]::interpret::place::MPlaceTy>
  19:     0x7fb02e727c27 - <rustc_mir_transform[b9926d443c571f20]::gvn::VnState>::eval_to_const
  20:     0x7fb02e74fccd - <rustc_mir_transform[b9926d443c571f20]::gvn::VnState as rustc_middle[96c442875f2cb62c]::mir::visit::MutVisitor>::visit_assign
  21:     0x7fb02e74c007 - <rustc_mir_transform[b9926d443c571f20]::gvn::GVN as rustc_mir_transform[b9926d443c571f20]::pass_manager::MirPass>::run_pass
  22:     0x7fb02da0891f - rustc_mir_transform[b9926d443c571f20]::run_optimization_passes
  23:     0x7fb02dea6518 - rustc_mir_transform[b9926d443c571f20]::optimized_mir
  24:     0x7fb02dea6177 - rustc_query_impl[5a309cdb9f26d392]::query_impl::optimized_mir::invoke_provider_fn::__rust_begin_short_backtrace
  25:     0x7fb02da47f4d - rustc_query_impl[5a309cdb9f26d392]::execution::try_execute_query::<rustc_middle[96c442875f2cb62c]::query::caches::DefIdCache<rustc_middle[96c442875f2cb62c]::query::erase::ErasedData<[u8; 8usize]>>, false>
  26:     0x7fb02da4750e - rustc_query_impl[5a309cdb9f26d392]::query_impl::optimized_mir::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7fb02de225e0 - rustc_mir_transform[b9926d443c571f20]::cross_crate_inline::cross_crate_inlinable
  28:     0x7fb02de21db9 - rustc_query_impl[5a309cdb9f26d392]::query_impl::cross_crate_inlinable::invoke_provider_fn::__rust_begin_short_backtrace
  29:     0x7fb02de1e789 - rustc_query_impl[5a309cdb9f26d392]::execution::try_execute_query::<rustc_middle[96c442875f2cb62c]::query::caches::DefIdCache<rustc_middle[96c442875f2cb62c]::query::erase::ErasedData<[u8; 1usize]>>, false>
  30:     0x7fb02de1e380 - rustc_query_impl[5a309cdb9f26d392]::query_impl::cross_crate_inlinable::execute_query_non_incr::__rust_end_short_backtrace
  31:     0x7fb02de2af3e - rustc_passes[8c4c1653f50cb3da]::reachable::reachable_set
  32:     0x7fb02eb4c970 - rustc_query_impl[5a309cdb9f26d392]::query_impl::reachable_set::invoke_provider_fn::__rust_begin_short_backtrace
  33:     0x7fb02eb47e1a - rustc_query_impl[5a309cdb9f26d392]::execution::try_execute_query::<rustc_middle[96c442875f2cb62c]::query::caches::SingleCache<rustc_middle[96c442875f2cb62c]::query::erase::ErasedData<[u8; 8usize]>>, false>
  34:     0x7fb02eb489f9 - rustc_query_impl[5a309cdb9f26d392]::query_impl::reachable_set::execute_query_non_incr::__rust_end_short_backtrace
  35:     0x7fb02e2287d0 - rustc_codegen_ssa[a1a5dff3a5e40db9]::back::symbol_export::reachable_non_generics_provider
  36:     0x7fb02e518b76 - rustc_query_impl[5a309cdb9f26d392]::query_impl::reachable_non_generics::invoke_provider_fn::__rust_begin_short_backtrace
  37:     0x7fb02e8bef96 - rustc_query_impl[5a309cdb9f26d392]::execution::try_execute_query::<rustc_data_structures[6044b2f767527520]::vec_cache::VecCache<rustc_span[157f53c51de8f998]::def_id::CrateNum, rustc_middle[96c442875f2cb62c]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[96c442875f2cb62c]::dep_graph::graph::DepNodeIndex>, false>
  38:     0x7fb02e8bd791 - rustc_query_impl[5a309cdb9f26d392]::query_impl::reachable_non_generics::execute_query_non_incr::__rust_end_short_backtrace
  39:     0x7fb02f1a8cdb - rustc_query_impl[5a309cdb9f26d392]::query_impl::is_reachable_non_generic::invoke_provider_fn::__rust_begin_short_backtrace.warm
  40:     0x7fb02de1e789 - rustc_query_impl[5a309cdb9f26d392]::execution::try_execute_query::<rustc_middle[96c442875f2cb62c]::query::caches::DefIdCache<rustc_middle[96c442875f2cb62c]::query::erase::ErasedData<[u8; 1usize]>>, false>
  41:     0x7fb02de1e198 - rustc_query_impl[5a309cdb9f26d392]::query_impl::is_reachable_non_generic::execute_query_non_incr::__rust_end_short_backtrace
  42:     0x7fb02e26fcbe - <rustc_monomorphize[e3dcef02742d2ef9]::collector::RootCollector>::push_if_root
  43:     0x7fb02e270d00 - rustc_monomorphize[e3dcef02742d2ef9]::collector::collect_roots
  44:     0x7fb02e57548a - rustc_monomorphize[e3dcef02742d2ef9]::partitioning::collect_and_partition_mono_items
  45:     0x7fb02eb45d66 - rustc_query_impl[5a309cdb9f26d392]::query_impl::collect_and_partition_mono_items::invoke_provider_fn::__rust_begin_short_backtrace
  46:     0x7fb02eb456c1 - rustc_query_impl[5a309cdb9f26d392]::execution::try_execute_query::<rustc_middle[96c442875f2cb62c]::query::caches::SingleCache<rustc_middle[96c442875f2cb62c]::query::erase::ErasedData<[u8; 24usize]>>, false>
  47:     0x7fb02eb4537c - rustc_query_impl[5a309cdb9f26d392]::query_impl::collect_and_partition_mono_items::execute_query_non_incr::__rust_end_short_backtrace
  48:     0x7fb02eca8704 - rustc_codegen_ssa[a1a5dff3a5e40db9]::base::codegen_crate::<rustc_codegen_llvm[f79ed61bf9e9a770]::LlvmCodegenBackend, rustc_codegen_llvm[f79ed61bf9e9a770]::ModuleLlvm>
  49:     0x7fb02eca840d - <rustc_codegen_llvm[f79ed61bf9e9a770]::LlvmCodegenBackend as rustc_codegen_ssa[a1a5dff3a5e40db9]::traits::backend::CodegenBackend>::codegen_crate
  50:     0x7fb02ea19ca4 - <rustc_interface[bb04609e4c960450]::queries::Linker>::codegen_and_build_linker
  51:     0x7fb02eb0470e - rustc_interface[bb04609e4c960450]::interface::run_compiler::<(), rustc_driver_impl[c2a64f8504684822]::run_compiler::{closure#0}>::{closure#2}
  52:     0x7fb02eb72ae4 - std[2a8c3cd46992084f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[bb04609e4c960450]::util::run_in_thread_with_globals<rustc_interface[bb04609e4c960450]::util::run_in_thread_pool_with_globals<rustc_interface[bb04609e4c960450]::interface::run_compiler<(), rustc_driver_impl[c2a64f8504684822]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  53:     0x7fb02eb728bb - <std[2a8c3cd46992084f]::thread::lifecycle::spawn_unchecked<rustc_interface[bb04609e4c960450]::util::run_in_thread_with_globals<rustc_interface[bb04609e4c960450]::util::run_in_thread_pool_with_globals<rustc_interface[bb04609e4c960450]::interface::run_compiler<(), rustc_driver_impl[c2a64f8504684822]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[f0447a45d83adb47]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  54:     0x7fb02eb7cec8 - <std[2a8c3cd46992084f]::sys::thread::unix::Thread>::new::thread_start
  55:     0x7fb028497739 - <unknown>
  56:     0x7fb02851bedc - <unknown>
  57:                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: please attach the file at `/tmp/A/rustc-ice-2026-07-19T18_53_47-1477999.txt` to your bug report

note: rustc 1.99.0-nightly (eff8269f7 2026-07-18) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3

query stack during panic:
#0 [optimized_mir] optimizing MIR for `<impl at a.rs:6:1: 6:17>::foo`
#1 [cross_crate_inlinable] whether the item should be made inlinable across crates
#2 [reachable_set] reachability
#3 [reachable_non_generics] looking up the exported symbols of a crate
#4 [is_reachable_non_generic] checking whether `<impl at a.rs:6:1: 6:17>::foo` is an exported symbol
#5 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to 1 previous error; 2 warnings emitted

Metadata

Metadata

Assignees

Labels

-Zvalidate-mirUnstable option: MIR validationA-mir-optArea: MIR optimizationsA-mir-opt-GVNArea: MIR opt Global Value Numbering (GVN)C-bugCategory: This is a bug.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.WG-mir-optWorking group: MIR optimizationsneeds-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

Type

No type

Fields

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