Skip to content

ICE invalid immediate for given destination place: value ScalarPair(..) does not match ABI Scalar(..) #144491

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -Zmir-opt-level=5 -Zvalidate-mir
trait A {}

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

original:

trait A {
    fn foo(&self) -> Self
    where
        Self: Copy;
}

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

fn foo(&self) -> Self
where
    Self: Copy,
{
    *(&[] as &[fn(&())])
}

Version information

rustc 1.90.0-nightly (f32b23204 2025-07-26)
binary: rustc
commit-hash: f32b23204a0efe2fe8383ed4be1a30b56c1bbf94
commit-date: 2025-07-26
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zmir-opt-level=5 -Zvalidate-mir

Program output

error[E0407]: method `foo` is not a member of trait `A`
 --> /tmp/icemaker_global_tempdir.fJ0VSfBik68G/rustc_testrunner_tmpdir_reporting.Klyirc38CjKJ/mvce.rs:4:5
  |
4 | /     fn foo(&self) -> Self
5 | |     where
6 | |         Self: Copy,
... |
9 | |     }
  | |_____^ not a member of trait `A`

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

error: internal compiler error: /rustc-dev/f32b23204a0efe2fe8383ed4be1a30b56c1bbf94/compiler/rustc_const_eval/src/interpret/operand.rs:158: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' panicked at /rustc-dev/f32b23204a0efe2fe8383ed4be1a30b56c1bbf94/compiler/rustc_const_eval/src/interpret/operand.rs:158:17:
Box<dyn Any>
stack backtrace:
   0:     0x7daa7c5bc083 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h2e79a3b5565365ab
   1:     0x7daa7ce02d77 - core::fmt::write::hd73b6fbae87cd0cb
   2:     0x7daa7c5b1ca3 - std::io::Write::write_fmt::he5af8bea889f5f24
   3:     0x7daa7c5bbee2 - std::sys::backtrace::BacktraceLock::print::he742169d5c6a0e72
   4:     0x7daa7c5bf987 - std::panicking::default_hook::{{closure}}::h4f20ca5ebdb93a0c
   5:     0x7daa7c5bf4eb - std::panicking::default_hook::h44f7c84a44bb8706
   6:     0x7daa7b631323 - std[8e1e6a238be51b8a]::panicking::update_hook::<alloc[2dda5eaef825109e]::boxed::Box<rustc_driver_impl[da72802e545f2ca3]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7daa7c5c01ce - std::panicking::rust_panic_with_hook::hedc500e28e47629e
   8:     0x7daa7b66a751 - std[8e1e6a238be51b8a]::panicking::begin_panic::<rustc_errors[877e7036bb87205d]::ExplicitBug>::{closure#0}
   9:     0x7daa7b65f6e6 - std[8e1e6a238be51b8a]::sys::backtrace::__rust_end_short_backtrace::<std[8e1e6a238be51b8a]::panicking::begin_panic<rustc_errors[877e7036bb87205d]::ExplicitBug>::{closure#0}, !>
  10:     0x7daa7b65f577 - std[8e1e6a238be51b8a]::panicking::begin_panic::<rustc_errors[877e7036bb87205d]::ExplicitBug>
  11:     0x7daa7b6741c1 - <rustc_errors[877e7036bb87205d]::diagnostic::BugAbort as rustc_errors[877e7036bb87205d]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7daa7bc76b3a - rustc_middle[b1846daf6b6bf63c]::util::bug::opt_span_bug_fmt::<rustc_span[eff6a45f3ede5b92]::span_encoding::Span>::{closure#0}
  13:     0x7daa7bc56f0a - rustc_middle[b1846daf6b6bf63c]::ty::context::tls::with_opt::<rustc_middle[b1846daf6b6bf63c]::util::bug::opt_span_bug_fmt<rustc_span[eff6a45f3ede5b92]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7daa7bc56d7b - rustc_middle[b1846daf6b6bf63c]::ty::context::tls::with_context_opt::<rustc_middle[b1846daf6b6bf63c]::ty::context::tls::with_opt<rustc_middle[b1846daf6b6bf63c]::util::bug::opt_span_bug_fmt<rustc_span[eff6a45f3ede5b92]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7daa78ccadd0 - rustc_middle[b1846daf6b6bf63c]::util::bug::bug_fmt
  16:     0x7daa7ec03591 - <rustc_const_eval[463abed4a6c7dfac]::interpret::operand::Immediate>::assert_matches_abi::<rustc_const_eval[463abed4a6c7dfac]::interpret::eval_context::InterpCx<rustc_const_eval[463abed4a6c7dfac]::const_eval::dummy_machine::DummyMachine>>.cold
  17:     0x7daa7db762ae - <rustc_const_eval[463abed4a6c7dfac]::interpret::eval_context::InterpCx<rustc_const_eval[463abed4a6c7dfac]::const_eval::dummy_machine::DummyMachine>>::write_immediate_to_mplace_no_validate
  18:     0x7daa7db76242 - <rustc_const_eval[463abed4a6c7dfac]::interpret::eval_context::InterpCx<rustc_const_eval[463abed4a6c7dfac]::const_eval::dummy_machine::DummyMachine>>::write_immediate_no_validate::<rustc_const_eval[463abed4a6c7dfac]::interpret::place::MPlaceTy>
  19:     0x7daa7db7910f - <rustc_const_eval[463abed4a6c7dfac]::interpret::eval_context::InterpCx<rustc_const_eval[463abed4a6c7dfac]::const_eval::dummy_machine::DummyMachine>>::unsize_into_ptr::<rustc_const_eval[463abed4a6c7dfac]::interpret::place::MPlaceTy>
  20:     0x7daa7db706a0 - <rustc_mir_transform[ed3e24971c04db5f]::gvn::VnState>::insert
  21:     0x7daa7db80c82 - <rustc_mir_transform[ed3e24971c04db5f]::gvn::VnState as rustc_middle[b1846daf6b6bf63c]::mir::visit::MutVisitor>::visit_assign
  22:     0x7daa7db7d558 - <rustc_mir_transform[ed3e24971c04db5f]::gvn::GVN as rustc_mir_transform[ed3e24971c04db5f]::pass_manager::MirPass>::run_pass
  23:     0x7daa7ce114bd - rustc_mir_transform[ed3e24971c04db5f]::run_optimization_passes
  24:     0x7daa7d73a7b8 - rustc_mir_transform[ed3e24971c04db5f]::optimized_mir
  25:     0x7daa7d739f9d - rustc_query_impl[9907fe0a1f275b0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9907fe0a1f275b0]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1846daf6b6bf63c]::query::erase::Erased<[u8; 8usize]>>
  26:     0x7daa7ce18e65 - rustc_query_system[50be2b71774c51e0]::query::plumbing::try_execute_query::<rustc_query_impl[9907fe0a1f275b0]::DynamicConfig<rustc_query_system[50be2b71774c51e0]::query::caches::DefIdCache<rustc_middle[b1846daf6b6bf63c]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[9907fe0a1f275b0]::plumbing::QueryCtxt, false>
  27:     0x7daa7ce1835b - rustc_query_impl[9907fe0a1f275b0]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7daa794e903b - <rustc_middle[b1846daf6b6bf63c]::ty::context::TyCtxt>::instance_mir
  29:     0x7daa7d5d2cd3 - rustc_interface[4e12820ca0b2e764]::passes::analysis
  30:     0x7daa7d5d1a49 - rustc_query_impl[9907fe0a1f275b0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9907fe0a1f275b0]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1846daf6b6bf63c]::query::erase::Erased<[u8; 0usize]>>
  31:     0x7daa7de3003c - rustc_query_system[50be2b71774c51e0]::query::plumbing::try_execute_query::<rustc_query_impl[9907fe0a1f275b0]::DynamicConfig<rustc_query_system[50be2b71774c51e0]::query::caches::SingleCache<rustc_middle[b1846daf6b6bf63c]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[9907fe0a1f275b0]::plumbing::QueryCtxt, false>
  32:     0x7daa7de2fc04 - rustc_query_impl[9907fe0a1f275b0]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7daa7ded550b - rustc_interface[4e12820ca0b2e764]::passes::create_and_enter_global_ctxt::<core[527c20722825abac]::option::Option<rustc_interface[4e12820ca0b2e764]::queries::Linker>, rustc_driver_impl[da72802e545f2ca3]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  34:     0x7daa7e0abd1e - rustc_interface[4e12820ca0b2e764]::interface::run_compiler::<(), rustc_driver_impl[da72802e545f2ca3]::run_compiler::{closure#0}>::{closure#1}
  35:     0x7daa7df652c1 - std[8e1e6a238be51b8a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[4e12820ca0b2e764]::util::run_in_thread_with_globals<rustc_interface[4e12820ca0b2e764]::util::run_in_thread_pool_with_globals<rustc_interface[4e12820ca0b2e764]::interface::run_compiler<(), rustc_driver_impl[da72802e545f2ca3]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  36:     0x7daa7df64fa2 - <<std[8e1e6a238be51b8a]::thread::Builder>::spawn_unchecked_<rustc_interface[4e12820ca0b2e764]::util::run_in_thread_with_globals<rustc_interface[4e12820ca0b2e764]::util::run_in_thread_pool_with_globals<rustc_interface[4e12820ca0b2e764]::interface::run_compiler<(), rustc_driver_impl[da72802e545f2ca3]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[527c20722825abac]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7daa7df6af7d - std::sys::pal::unix::thread::Thread::new::thread_start::h511a30c1a1da8f57
  38:     0x7daa778a57eb - <unknown>
  39:     0x7daa7792918c - <unknown>
  40:                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.90.0-nightly (f32b23204 2025-07-26) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=5 -Z validate-mir -Z dump-mir-dir=dir

query stack during panic:
#0 [optimized_mir] optimizing MIR for `<impl at /tmp/icemaker_global_tempdir.fJ0VSfBik68G/rustc_testrunner_tmpdir_reporting.Klyirc38CjKJ/mvce.rs:3:1: 3:17>::foo`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impossible-boundsArea: Issues related to have impossible trait bounds in scope (impossible predicates)A-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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions