Repository: rust
Issue: ICE: `invalid immediate for given destination place: value ScalarPair .. does not match ABI`
Labels: I-ICE,T-compiler,C-bug,A-mir-opt-inlining,S-bug-has-test,F-non_lifetime_binders,A-mir-opt-GVN

<!--
[31mICE[0m: Rustc ./a.rs '-Zmir-opt-level=5 -Zvalidate-mir -Zcrate-attr=feature(non_lifetime_binders) -ooutputfile -Zdump-mir-dir=dir' 'error: internal compiler error: compiler/rustc_const_eval/src/interpret/operand.rs:157:17: invalid immediate for given destination place: value ScalarPair(alloc5<imm>, 0x0000000000000001) does not match ABI Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }))', 'error: internal compiler error: compiler/rustc_const_eval/src/interpret/operand.rs:157:17: invalid immediate for given destination place: value ScalarPair(alloc5<imm>, 0x0000000000000001) does not match ABI Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }))'
File: /tmp/im/a.rs
-->

auto-reduced (treereduce-rust):
````rust
#![feature(non_lifetime_binders)]
fn Brick()
where
    for<T> T: Copy,
{
    let mut foo: Option<Box<_>> = Some(Box::new(8));
    let f = move || {
        println!("'{}'", foo.unwrap());
    };
    f();
}

````

original:
````rust
#![feature(attr_literals)]

fn Brick() where for<T> T: Copy {
    let mut foo: Option<Box<_>> = Some(Box::new(8));
    let f = move|| {
        match foo {
            None => {},
            Some(x) => {
                foo = Some(x);
            }
        }
        println!("'{}'", foo.unwrap());
    };
    f();
}

fn main() {
    foo();
}

````

Version information
````
rustc 1.83.0-nightly (8d94e06ec 2024-10-10)
binary: rustc
commit-hash: 8d94e06ec9758b5c03ea77bb5dab22a1a76bc261
commit-date: 2024-10-10
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.1

````

Command:
`/home/matthias/.rustup/toolchains/master/bin/rustc -Zmir-opt-level=5 -Zvalidate-mir -Zcrate-attr=feature(non_lifetime_binders)`

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Program output</strong></summary>
<p>

```
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:9
  |
1 | feature(non_lifetime_binders)
  |         ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
  = note: `#[warn(incomplete_features)]` on by default

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

warning: variable does not need to be mutable
 --> /tmp/icemaker_global_tempdir.UkDLZIiGWuhn/rustc_testrunner_tmpdir_reporting.sOtl1K9lpDK5/mvce.rs:5:9
  |
5 |     let mut foo: Option<Box<_>> = Some(Box::new(8));
  |         ----^^^
  |         |
  |         help: remove this `mut`
  |
  = note: `#[warn(unused_mut)]` on by default

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

thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/operand.rs:157:17:
Box<dyn Any>
stack backtrace:
   0:     0x71a61e1d6a5a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::ha20e66cea8d40da6
   1:     0x71a61ea034a6 - core::fmt::write::hf2daaa73a1dc1c93
   2:     0x71a61fc02e51 - std::io::Write::write_fmt::h378271f9be5fe2f8
   3:     0x71a61e1d68b2 - std::sys::backtrace::BacktraceLock::print::hc64e8d2bde51fd49
   4:     0x71a61e1d8d86 - std::panicking::default_hook::{{closure}}::h0d83bed2db8cab1c
   5:     0x71a61e1d8bd0 - std::panicking::default_hook::h128ef1b79513126f
   6:     0x71a61d22df6f - std[a9199b77cdff7b9b]::panicking::update_hook::<alloc[226919ebccef61a6]::boxed::Box<rustc_driver_impl[92ba7bf89b2038aa]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x71a61e1d9498 - std::panicking::rust_panic_with_hook::h5cd591a4b9cf7e7b
   8:     0x71a61d267a51 - std[a9199b77cdff7b9b]::panicking::begin_panic::<rustc_errors[62337987763b3873]::ExplicitBug>::{closure#0}
   9:     0x71a61d25aaf6 - std[a9199b77cdff7b9b]::sys::backtrace::__rust_end_short_backtrace::<std[a9199b77cdff7b9b]::panicking::begin_panic<rustc_errors[62337987763b3873]::ExplicitBug>::{closure#0}, !>
  10:     0x71a61d25aab3 - std[a9199b77cdff7b9b]::panicking::begin_panic::<rustc_errors[62337987763b3873]::ExplicitBug>
  11:     0x71a61d2712e1 - <rustc_errors[62337987763b3873]::diagnostic::BugAbort as rustc_errors[62337987763b3873]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x71a61d8ca144 - rustc_middle[d89ba7dfe97f8d9e]::util::bug::opt_span_bug_fmt::<rustc_span[80b8a8e8ce77617b]::span_encoding::Span>::{closure#0}
  13:     0x71a61d8affca - rustc_middle[d89ba7dfe97f8d9e]::ty::context::tls::with_opt::<rustc_middle[d89ba7dfe97f8d9e]::util::bug::opt_span_bug_fmt<rustc_span[80b8a8e8ce77617b]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x71a61d8afe5b - rustc_middle[d89ba7dfe97f8d9e]::ty::context::tls::with_context_opt::<rustc_middle[d89ba7dfe97f8d9e]::ty::context::tls::with_opt<rustc_middle[d89ba7dfe97f8d9e]::util::bug::opt_span_bug_fmt<rustc_span[80b8a8e8ce77617b]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x71a61adf99a0 - rustc_middle[d89ba7dfe97f8d9e]::util::bug::bug_fmt
  16:     0x71a61c1dbf23 - <rustc_const_eval[71c2be5c4d1e6846]::interpret::eval_context::InterpCx<rustc_const_eval[71c2be5c4d1e6846]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
  17:     0x71a61c173403 - rustc_const_eval[71c2be5c4d1e6846]::const_eval::eval_queries::eval_to_allocation_raw_provider
  18:     0x71a61f11f2f6 - rustc_query_impl[121dfa8c420f6771]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[121dfa8c420f6771]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 24usize]>>
  19:     0x71a61f11eb1a - rustc_query_system[f00ba4d010ca6a7e]::query::plumbing::try_execute_query::<rustc_query_impl[121dfa8c420f6771]::DynamicConfig<rustc_query_system[f00ba4d010ca6a7e]::query::caches::DefaultCache<rustc_middle[d89ba7dfe97f8d9e]::ty::ParamEnvAnd<rustc_middle[d89ba7dfe97f8d9e]::mir::interpret::GlobalId>, rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[121dfa8c420f6771]::plumbing::QueryCtxt, false>
  20:     0x71a61f11e6ef - rustc_query_impl[121dfa8c420f6771]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  21:     0x71a61f12055f - rustc_const_eval[71c2be5c4d1e6846]::const_eval::eval_queries::eval_to_const_value_raw_provider
  22:     0x71a61f120376 - rustc_query_impl[121dfa8c420f6771]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[121dfa8c420f6771]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 24usize]>>
  23:     0x71a61f11eadd - rustc_query_system[f00ba4d010ca6a7e]::query::plumbing::try_execute_query::<rustc_query_impl[121dfa8c420f6771]::DynamicConfig<rustc_query_system[f00ba4d010ca6a7e]::query::caches::DefaultCache<rustc_middle[d89ba7dfe97f8d9e]::ty::ParamEnvAnd<rustc_middle[d89ba7dfe97f8d9e]::mir::interpret::GlobalId>, rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[121dfa8c420f6771]::plumbing::QueryCtxt, false>
  24:     0x71a61f11e5f3 - rustc_query_impl[121dfa8c420f6771]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
  25:     0x71a61b620a96 - <rustc_middle[d89ba7dfe97f8d9e]::ty::context::TyCtxt>::const_eval_resolve
  26:     0x71a61f4d7074 - <rustc_mir_transform[494498406daaddfd]::gvn::VnState>::insert
  27:     0x71a61f4d2d4d - <rustc_mir_transform[494498406daaddfd]::gvn::VnState>::simplify_operand
  28:     0x71a61be885f4 - <rustc_mir_transform[494498406daaddfd]::gvn::GVN as rustc_mir_transform[494498406daaddfd]::pass_manager::MirPass>::run_pass
  29:     0x71a61ea0b70d - rustc_mir_transform[494498406daaddfd]::pass_manager::run_passes_inner
  30:     0x71a61ed082e2 - rustc_mir_transform[494498406daaddfd]::optimized_mir
  31:     0x71a61ed06ba1 - rustc_query_impl[121dfa8c420f6771]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[121dfa8c420f6771]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 8usize]>>
  32:     0x71a61ed58778 - rustc_query_system[f00ba4d010ca6a7e]::query::plumbing::try_execute_query::<rustc_query_impl[121dfa8c420f6771]::DynamicConfig<rustc_query_system[f00ba4d010ca6a7e]::query::caches::DefIdCache<rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[121dfa8c420f6771]::plumbing::QueryCtxt, false>
  33:     0x71a61ed57d33 - rustc_query_impl[121dfa8c420f6771]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  34:     0x71a61bcd0cc4 - <rustc_middle[d89ba7dfe97f8d9e]::ty::context::TyCtxt>::instance_mir
  35:     0x71a61ee7b30a - rustc_interface[70865a4857b6d971]::passes::run_required_analyses
  36:     0x71a61f75c35e - rustc_interface[70865a4857b6d971]::passes::analysis
  37:     0x71a61f75c331 - rustc_query_impl[121dfa8c420f6771]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[121dfa8c420f6771]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 1usize]>>
  38:     0x71a61f8fc62e - rustc_query_system[f00ba4d010ca6a7e]::query::plumbing::try_execute_query::<rustc_query_impl[121dfa8c420f6771]::DynamicConfig<rustc_query_system[f00ba4d010ca6a7e]::query::caches::SingleCache<rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[121dfa8c420f6771]::plumbing::QueryCtxt, false>
  39:     0x71a61f8fc30f - rustc_query_impl[121dfa8c420f6771]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x71a61f753b5e - rustc_interface[70865a4857b6d971]::interface::run_compiler::<core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>, rustc_driver_impl[92ba7bf89b2038aa]::run_compiler::{closure#0}>::{closure#1}
  41:     0x71a61f7d9450 - std[a9199b77cdff7b9b]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[70865a4857b6d971]::util::run_in_thread_with_globals<rustc_interface[70865a4857b6d971]::util::run_in_thread_pool_with_globals<rustc_interface[70865a4857b6d971]::interface::run_compiler<core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>, rustc_driver_impl[92ba7bf89b2038aa]::run_compiler::{closure#0}>::{closure#1}, core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>>::{closure#0}, core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>>
  42:     0x71a61f7d9b17 - <<std[a9199b77cdff7b9b]::thread::Builder>::spawn_unchecked_<rustc_interface[70865a4857b6d971]::util::run_in_thread_with_globals<rustc_interface[70865a4857b6d971]::util::run_in_thread_pool_with_globals<rustc_interface[70865a4857b6d971]::interface::run_compiler<core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>, rustc_driver_impl[92ba7bf89b2038aa]::run_compiler::{closure#0}>::{closure#1}, core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>>::{closure#0}, core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>>::{closure#1} as core[a4436d16a4783843]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x71a61f7daa01 - std::sys::pal::unix::thread::Thread::new::thread_start::h1576647e75736287
  44:     0x71a620e6139d - <unknown>
  45:     0x71a620ee649c - <unknown>
  46:                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.83.0-nightly (8d94e06ec 2024-10-10) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=5 -Z validate-mir -Z crate-attr=feature(non_lifetime_binders) -Z dump-mir-dir=dir

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `Brick::{closure#0}::promoted[0]`
#1 [eval_to_const_value_raw] simplifying constant for the type system `Brick::{closure#0}::promoted[0]`
end of query stack
error: aborting due to 2 previous errors; 2 warnings emitted

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

```

</p>
</details>

<!--
query stack:
#0 [eval_to_allocation_raw] const-evaluating + checking `Brick::{closure#0}::promoted[0]`
#1 [eval_to_const_value_raw] simplifying constant for the type system `Brick::{closure#0}::promoted[0]`

-->
@rustbot label +F-non_lifetime_binders