Skip to content

Crash on compiler\rustc_const_eval\src\interpret\operand.rs:157:17 due to async and where constraints #135546

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
sososopy opened this issue Jan 15, 2025 · 2 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@sososopy
Copy link

I tried this code:

async fn foo() -> Box<[fn(&())]>
where
    [fn(&())]: Copy,
{
    Box::new(*(&[] as &[_]))
}
fn main() {
    
}

Meta

rustc --version --verbose:

rustc 1.86.0-nightly (8361aef0d 2025-01-14)
binary: rustc
commit-hash: 8361aef0d7c29b1501a316a208ed84cd8a2ae5da
commit-date: 2025-01-14
host: x86_64-pc-windows-msvc
release: 1.86.0-nightly
LLVM version: 19.1.6

Compilation condition

rustc -C opt-level=1 --edition 2021

Error output

error: internal compiler error: /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da\compiler\rustc_const_eval\src\interpret\operand.rs:157: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 }))
Backtrace

thread 'rustc' panicked at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da\compiler\rustc_const_eval\src\interpret\operand.rs:157:17:
Box<dyn Any>
stack backtrace:
   0:     0x7ffa8732ebd1 - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ffa8732ebd1 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffa8732ebd1 - std::sys::backtrace::_print_fmt
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\std\src\sys\backtrace.rs:66
   3:     0x7ffa8732ebd1 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\std\src\sys\backtrace.rs:39
   4:     0x7ffa8736197a - core::fmt::rt::Argument::fmt
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\core\src\fmt\rt.rs:177
   5:     0x7ffa8736197a - core::fmt::write
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\core\src\fmt\mod.rs:1440
   6:     0x7ffa87324807 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\std\src\io\mod.rs:1887
   7:     0x7ffa8732ea15 - std::sys::backtrace::BacktraceLock::print
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\std\src\sys\backtrace.rs:42
   8:     0x7ffa87331a5d - std::panicking::default_hook::closure$1
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\std\src\panicking.rs:295
   9:     0x7ffa873317c0 - std::panicking::default_hook
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\std\src\panicking.rs:322
  10:     0x7ffa8893f28a - core[5f2117184623a275]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[3618592bbbf5e09]::Level, &str), usize), <((rustc_lint_defs[3618592bbbf5e09]::Level, &str), usize) as core[5f2117184623a275]::cmp::PartialOrd>::lt>
  11:     0x7ffa8733234e - alloc::boxed::impl$30::call
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\alloc\src\boxed.rs:2027
  12:     0x7ffa8733234e - std::panicking::rust_panic_with_hook
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\std\src\panicking.rs:836
  13:     0x7ffa8a00a473 - RINvNtNtNtNtCs8amZoMuM9uH_4core5slice4sort6stable9quicksort9quicksortTjRNtNtCsiwyFVH1BZ9G_12rustc_errors7snippet10AnnotationENCINvMNtCseNN7UnzpnC0_5alloc5sliceSB15_11sort_by_keyTINtNtBa_3cmp7ReversejEbENCNCNvMs5_NtB1c_7emitterNtB3o_12HumanEmitter18render_s
  14:     0x7ffa89ffe6d9 - std[bb336b0c9ab77cd9]::sys::backtrace::__rust_end_short_backtrace::<std[bb336b0c9ab77cd9]::panicking::begin_panic<rustc_errors[d7c61cf04ba85696]::ExplicitBug>::{closure#0}, !>
  15:     0x7ffa89ffe6b8 - std[bb336b0c9ab77cd9]::panicking::begin_panic::<rustc_errors[d7c61cf04ba85696]::ExplicitBug>
  16:     0x7ffa8a017525 - <rustc_errors[d7c61cf04ba85696]::diagnostic::BugAbort as rustc_errors[d7c61cf04ba85696]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  17:     0x7ffa89f5d732 - rustc_middle[ddb4ae194d7498f8]::util::bug::span_bug_fmt::<rustc_span[28e015a95f238d3b]::span_encoding::Span>
  18:     0x7ffa89f3d5ad - <rustc_middle[ddb4ae194d7498f8]::ty::consts::Const>::to_valtree
  19:     0x7ffa89f3d3c6 - <rustc_middle[ddb4ae194d7498f8]::ty::consts::Const>::to_valtree
  20:     0x7ffa89f5d632 - rustc_middle[ddb4ae194d7498f8]::util::bug::bug_fmt
  21:     0x7ffa86c7329d - RINvNtNtNtNtCs8amZoMuM9uH_4core5slice4sort6stable9quicksort9quicksortNtNtNtCsj28lGiu3QLY_12rustc_middle3mir4mono11CodegenUnitNCINvMNtCseNN7UnzpnC0_5alloc5sliceSB15_7sort_byNCNvNtCsbzZKfDk6GzP_18rustc_monomorphize12partitioning19merge_codegen_unitss4_0E0EB2
  22:     0x7ffa86c91898 - <alloc[ac6bbfcc7020619a]::raw_vec::RawVec<(rustc_middle[ddb4ae194d7498f8]::mir::Location, rustc_middle[ddb4ae194d7498f8]::mir::statement::Statement)>>::grow_one
  23:     0x7ffa86c73efd - RINvNtNtNtNtCs8amZoMuM9uH_4core5slice4sort6stable9quicksort9quicksortNtNtNtCsj28lGiu3QLY_12rustc_middle3mir4mono11CodegenUnitNCINvMNtCseNN7UnzpnC0_5alloc5sliceSB15_7sort_byNCNvNtCsbzZKfDk6GzP_18rustc_monomorphize12partitioning19merge_codegen_unitss4_0E0EB2
  24:     0x7ffa86c7e78d - RINvNtNtNtNtCs8amZoMuM9uH_4core5slice4sort6stable9quicksort9quicksortTNtNtCsj28lGiu3QLY_12rustc_middle3mir8LocationNtNtB18_9statement9StatementENCINvMNtCseNN7UnzpnC0_5alloc5sliceSB15_11sort_by_keyINtNtBa_3cmp7ReverseB16_ENCNvNtCskulYgXLsodh_19rustc_mir_tra
  25:     0x7ffa86c7ddc0 - RINvNtNtNtNtCs8amZoMuM9uH_4core5slice4sort6stable9quicksort9quicksortTNtNtCsj28lGiu3QLY_12rustc_middle3mir8LocationNtNtB18_9statement9StatementENCINvMNtCseNN7UnzpnC0_5alloc5sliceSB15_11sort_by_keyINtNtBa_3cmp7ReverseB16_ENCNvNtCskulYgXLsodh_19rustc_mir_tra
  26:     0x7ffa8786b6ab - <rustc_mir_transform[eea7a6ff0733ad49]::inline::NormalInliner as rustc_mir_transform[eea7a6ff0733ad49]::inline::Inliner>::check_callee_mir_body
  27:     0x7ffa87862ee3 - <rustc_mir_transform[eea7a6ff0733ad49]::inline::NormalInliner as rustc_mir_transform[eea7a6ff0733ad49]::inline::Inliner>::check_callee_mir_body
  28:     0x7ffa8787827a - <rustc_mir_transform[eea7a6ff0733ad49]::gvn::GVN as rustc_mir_transform[eea7a6ff0733ad49]::pass_manager::MirPass>::run_pass
  29:     0x7ffa87772200 - <rustc_mir_transform[eea7a6ff0733ad49]::simplify::SimplifyCfg as rustc_mir_transform[eea7a6ff0733ad49]::pass_manager::MirPass>::run_pass
  30:     0x7ffa8779e2a4 - rustc_mir_transform[eea7a6ff0733ad49]::optimized_mir
  31:     0x7ffa880dc040 - rustc_query_impl[36e9325f2b24a56b]::plumbing::query_key_hash_verify_all
  32:     0x7ffa87fb7b93 - RINvNtNtCscx25HfZ04Tn_18rustc_query_system5query8plumbing17try_execute_queryINtCs4IhX5l9GGKZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches10DefIdCacheINtNtNtCsj28lGiu3QLY_12rustc_middle5query5erase6ErasedAhj8_EEKb0_KB3r_KB3r_ENtNtB1f_8plumbing9QueryCtxt
  33:     0x7ffa880e2725 - rustc_query_impl[36e9325f2b24a56b]::plumbing::query_key_hash_verify_all
  34:     0x7ffa887b58a8 - <rustc_middle[ddb4ae194d7498f8]::query::on_disk_cache::CacheEncoder as rustc_span[28e015a95f238d3b]::SpanEncoder>::encode_def_id
  35:     0x7ffa89f5cef7 - <rustc_middle[ddb4ae194d7498f8]::ty::context::TyCtxt>::coroutine_layout
  36:     0x7ffa89672efb - rustc_ty_utils[926fffe7043ec7]::consts::destructure_const
  37:     0x7ffa87f4d3b4 - rustc_ty_utils[926fffe7043ec7]::instance::resolve_instance_raw
  38:     0x7ffa87f6b8fc - rustc_ty_utils[926fffe7043ec7]::layout::layout_of
  39:     0x7ffa880ddefe - rustc_query_impl[36e9325f2b24a56b]::plumbing::query_key_hash_verify_all
  40:     0x7ffa87fd8d7e - RINvNtNtCscx25HfZ04Tn_18rustc_query_system5query8plumbing17try_execute_queryINtCs4IhX5l9GGKZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCsj28lGiu3QLY_12rustc_middle2ty20PseudoCanonicalInputNtB2w_2TyEINtNtNtB2y_5query5erase6ErasedAhj
  41:     0x7ffa880ebc9c - rustc_query_impl[36e9325f2b24a56b]::plumbing::query_key_hash_verify_all
  42:     0x7ffa877d6044 - <rustc_mir_transform[eea7a6ff0733ad49]::known_panics_lint::KnownPanicsLint as rustc_mir_transform[eea7a6ff0733ad49]::pass_manager::MirLint>::run_lint
  43:     0x7ffa87796dbc - rustc_mir_transform[eea7a6ff0733ad49]::run_analysis_to_runtime_passes
  44:     0x7ffa8779529e - rustc_mir_transform[eea7a6ff0733ad49]::mir_drops_elaborated_and_const_checked
  45:     0x7ffa880dd9db - rustc_query_impl[36e9325f2b24a56b]::plumbing::query_key_hash_verify_all
  46:     0x7ffa8801b549 - RINvNtNtCscx25HfZ04Tn_18rustc_query_system5query8plumbing17try_execute_queryINtCs4IhX5l9GGKZ_16rustc_query_impl13DynamicConfigINtNtCserR570K6NMb_21rustc_data_structures9vec_cache8VecCacheNtNtCs3vzRsW9pnbH_10rustc_span6def_id10LocalDefIdINtNtNtCsj28lGiu3QLY
  47:     0x7ffa880e23f3 - rustc_query_impl[36e9325f2b24a56b]::plumbing::query_key_hash_verify_all
  48:     0x7ffa873ab971 - rustc_interface[ec4b8daf2443de8]::passes::resolver_for_lowering_raw
  49:     0x7ffa8438883e - rustc_interface[ec4b8daf2443de8]::passes::analysis
  50:     0x7ffa86f2f17a - <alloc[ac6bbfcc7020619a]::sync::Arc<rustc_session[3204f9ac2d45cc71]::cstore::CrateSource>>::drop_slow
  51:     0x7ffa86e3ec24 - RINvNtNtCscx25HfZ04Tn_18rustc_query_system5query8plumbing17try_execute_queryINtCs4IhX5l9GGKZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCsj28lGiu3QLY_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
  52:     0x7ffa86f34e47 - rustc_query_impl[36e9325f2b24a56b]::query_system
  53:     0x7ffa8434e5a6 - RINvNtNtCsg4sSjJ8OiTJ_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCseNN7UnzpnC0_5alloc5boxed3BoxDINtNtNtCs8amZoMuM9uH_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECshLE
  54:     0x7ffa84346f6e - RINvNtNtCsg4sSjJ8OiTJ_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCseNN7UnzpnC0_5alloc5boxed3BoxDINtNtNtCs8amZoMuM9uH_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECshLE
  55:     0x7ffa8433ffc9 - RINvNtNtCsg4sSjJ8OiTJ_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCs1gBWS7Kn4p0_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCshLEr71jNQtL_17rustc_driver_i
  56:     0x7ffa843533b0 - RINvNtNtCsg4sSjJ8OiTJ_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCseNN7UnzpnC0_5alloc5boxed3BoxDINtNtNtCs8amZoMuM9uH_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECshLE
  57:     0x7ffa873443ed - alloc::boxed::impl$28::call_once
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\alloc\src\boxed.rs:2013
  58:     0x7ffa873443ed - alloc::boxed::impl$28::call_once
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\alloc\src\boxed.rs:2013
  59:     0x7ffa873443ed - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/8361aef0d7c29b1501a316a208ed84cd8a2ae5da/library\std\src\sys\pal\windows\thread.rs:56
  60:     0x7ffb54ff7374 - BaseThreadInitThunk
  61:     0x7ffb5513cc91 - RtlUserThreadStart

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 `D:\rust_test\test1\src\rustc-ice-2025-01-15T13_03_58-3640.txt` to your bug report

note: compiler flags: -C opt-level=1

query stack during panic:
#0 [optimized_mir] optimizing MIR for `foo::{closure#0}`
#1 [layout_of] computing layout of `{async fn body of foo()}`
end of query stack
error: aborting due to 1 previous error

stable and nightly both crash when O1 optimization is turned on

@sososopy sososopy added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 15, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 15, 2025
@theemathas
Copy link
Contributor

theemathas commented Jan 15, 2025

Minimized:

async fn foo()
where
    for<'a> [i32]: Copy,
{
    let _x = *(&[] as &[i32]);
}

Seems to be a duplicate of #135128

@jieyouxu
Copy link
Member

Yeah, I believe this is indeed a duplicate of #135128.

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 24, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants