Skip to content

ICE:called Option::unwrap() on a None value #140469

New issue

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

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

Already on GitHub? Sign in to your account

Open
sososopy opened this issue Apr 29, 2025 · 1 comment
Open

ICE:called Option::unwrap() on a None value #140469

sososopy opened this issue Apr 29, 2025 · 1 comment
Labels
A-async-await Area: Async & Await A-const-prop Area: Constant propagation C-bug Category: This is a bug. F-async_drop Async drop I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features This issue requires the use of incomplete features. S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@sososopy
Copy link

Code

#![feature(async_drop)]
fn func<const N: usize>(x: [&[i32]; N]) {
    || {
        for i in x {
            yield();
        }
    };
}

Meta

rustc --version --verbose:

rustc 1.88.0-nightly (25cdf1f67 2025-04-28)
binary: rustc
commit-hash: 25cdf1f67463c9365d8d83778c933ec7480e940b
commit-date: 2025-04-28
host: x86_64-pc-windows-msvc
release: 1.88.0-nightly
LLVM version: 20.1.2

Error output

error[E0658]: yield syntax is experimental
   --> .\ttt\test.rs:265:13
    |
265 |             yield();
    |             ^^^^^^^
    |
    = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
    = help: add `#![feature(coroutines)]` to the crate attributes to enable
    = note: this compiler was built on 2025-04-28; consider upgrading it if it is out of date

warning: the feature `async_drop` is incomplete and may not be safe to use and/or cause compiler crashes
   --> .\ttt\test.rs:261:12
    |
261 | #![feature(async_drop)]
    |            ^^^^^^^^^^
    |
    = note: see issue #126482 <https://github.com/rust-lang/rust/issues/126482> for more information
    = note: `#[warn(incomplete_features)]` on by default

error[E0658]: yield syntax is experimental
   --> .\ttt\test.rs:265:13
    |
265 |             yield();
    |             ^^^^^^^
    |
    = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
    = help: add `#![feature(yield_expr)]` to the crate attributes to enable
    = note: this compiler was built on 2025-04-28; consider upgrading it if it is out of date

error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
   --> .\ttt\test.rs:265:13
    |
265 |             yield();
    |             ^^^^^^^
    |
help: use `#[coroutine]` to make this closure a coroutine
    |
263 |     #[coroutine] || {
    |     ++++++++++++

error[E0601]: `main` function not found in crate `test`
   --> .\ttt\test.rs:268:2
    |
268 | }
    |  ^ consider adding a `main` function to `.\ttt\test.rs`
Backtrace

thread 'rustc' panicked at compiler\rustc_middle\src\ty\sty.rs:364:36:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7ffde70e7772 - std::backtrace_rs::backtrace::win64::trace
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
   1:     0x7ffde70e7772 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffde70e7772 - std::sys::backtrace::_print_fmt
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\std\src\sys\backtrace.rs:66
   3:     0x7ffde70e7772 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\std\src\sys\backtrace.rs:39
   4:     0x7ffde711a2bb - core::fmt::rt::Argument::fmt
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\core\src\fmt\rt.rs:179
   5:     0x7ffde711a2bb - core::fmt::write
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\core\src\fmt\mod.rs:1481
   6:     0x7ffde70dda27 - std::io::default_write_fmt
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\std\src\io\mod.rs:639
   7:     0x7ffde70dda27 - std::io::Write::write_fmt<std::sys::stdio::windows::Stderr>
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\std\src\io\mod.rs:1914
   8:     0x7ffde70e75b5 - std::sys::backtrace::BacktraceLock::print
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\std\src\sys\backtrace.rs:42
   9:     0x7ffde70ed25a - std::panicking::default_hook::closure$0
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\std\src\panicking.rs:300
  10:     0x7ffde70ecff0 - std::panicking::default_hook
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\std\src\panicking.rs:327
  11:     0x7ffde87e16f9 - core[78e2a688f80d3516]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[f9c30a40a5d8fca2]::Level, &str), usize), <((rustc_lint_defs[f9c30a40a5d8fca2]::Level, &str), usize) as core[78e2a688f80d3516]::cmp::PartialOrd>::lt>
  12:     0x7ffde70edeee - std::panicking::rust_panic_with_hook
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\std\src\panicking.rs:841
  13:     0x7ffde70edc12 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\std\src\panicking.rs:699
  14:     0x7ffde70e852f - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\std\src\sys\backtrace.rs:168
  15:     0x7ffde70ed84e - std::panicking::begin_panic_handler
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\std\src\panicking.rs:697
  16:     0x7ffdea228001 - core::panicking::panic_fmt
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\core\src\panicking.rs:75
  17:     0x7ffdea2280bd - core::panicking::panic
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\core\src\panicking.rs:145
  18:     0x7ffdea227f7e - core::option::unwrap_failed
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\core\src\option.rs:2040
  19:     0x7ffde6f79996 - <rustc_middle[223a725a3241bbc2]::ty::sty::ParamConst>::find_ty_from_env
  20:     0x7ffde81a1a30 - <rustc_trait_selection[e44406e7d0a46219]::traits::query::normalize::QueryNormalizer as rustc_type_ir[b1b4bfd106a80022]::fold::FallibleTypeFolder<rustc_middle[223a725a3241bbc2]::ty::context::TyCtxt>>::try_fold_ty
  21:     0x7ffde81a6197 - <rustc_trait_selection[e44406e7d0a46219]::traits::query::normalize::QueryNormalizer as rustc_type_ir[b1b4bfd106a80022]::fold::FallibleTypeFolder<rustc_middle[223a725a3241bbc2]::ty::context::TyCtxt>>::try_fold_ty
  22:     0x7ffde80dfc0c - <rustc_trait_selection[e44406e7d0a46219]::traits::select::SelectionContext>::evaluate_root_obligation
  23:     0x7ffde796331e - rustc_traits[d4be836249d80e20]::evaluate_obligation::evaluate_obligation
  24:     0x7ffde801cb8e - rustc_query_impl[6f45aaa328468e93]::plumbing::query_key_hash_verify_all
  25:     0x7ffde7f15e58 - RINvNtNtCs1k3oNJgFkWS_18rustc_query_system5query8plumbing17try_execute_queryINtCs9yixdmdYRUZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCsffVmfNnCV1u_13rustc_type_ir9canonical19CanonicalQueryInputNtNtNtCs2WcbfYfVIWs_12rustc_middle2t
  26:     0x7ffde802f290 - rustc_query_impl[6f45aaa328468e93]::plumbing::query_key_hash_verify_all
  27:     0x7ffde814ab95 - <rustc_infer[451d1c64d0bb9a13]::infer::InferCtxt as rustc_trait_selection[e44406e7d0a46219]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  28:     0x7ffde81005cc - rustc_trait_selection[e44406e7d0a46219]::traits::type_known_to_meet_bound_modulo_regions
  29:     0x7ffde7df6491 - rustc_ty_utils[45a1d957d15ee6cd]::common_traits::is_copy_raw
  30:     0x7ffde801bb04 - rustc_query_impl[6f45aaa328468e93]::plumbing::query_key_hash_verify_all
  31:     0x7ffde7efce96 - RINvNtNtCs1k3oNJgFkWS_18rustc_query_system5query8plumbing17try_execute_queryINtCs9yixdmdYRUZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCs2WcbfYfVIWs_12rustc_middle2ty20PseudoCanonicalInputNtB2w_2TyEINtNtNtB2y_5query5erase6ErasedAhj
  32:     0x7ffde802b436 - rustc_query_impl[6f45aaa328468e93]::plumbing::query_key_hash_verify_all
  33:     0x7ffde863f45f - <rustc_middle[223a725a3241bbc2]::ty::context::TyCtxt>::type_is_copy_modulo_regions
  34:     0x7ffde96135af - rustc_ty_utils[45a1d957d15ee6cd]::needs_drop::needs_async_drop_raw
  35:     0x7ffde9860495 - <rustc_query_impl[6f45aaa328468e93]::plumbing::QueryCtxt as rustc_query_system[f6a4bac142582ec]::query::QueryContext>::depth_limit_error     
  36:     0x7ffde982cc63 - <rustc_query_system[f6a4bac142582ec]::query::plumbing::JobOwner<(), rustc_query_system[f6a4bac142582ec]::query::QueryStackDeferred> as core[78e2a688f80d3516]::ops::drop::Drop>::drop
  37:     0x7ffde7efd2ec - RINvNtNtCs1k3oNJgFkWS_18rustc_query_system5query8plumbing17try_execute_queryINtCs9yixdmdYRUZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCs2WcbfYfVIWs_12rustc_middle2ty20PseudoCanonicalInputNtB2w_2TyEINtNtNtB2y_5query5erase6ErasedAhj
  38:     0x7ffde9886202 - <rustc_span[a6ac15f15f288c95]::def_id::DefIndex as rustc_query_impl[6f45aaa328468e93]::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string
  39:     0x7ffde8ede2ab - <alloc[5ee769a2c16ffbe5]::collections::vec_deque::VecDeque<&mut rustc_mir_transform[df85c3740367f631]::coverage::mappings::MCDCBranch>>::grow  40:     0x7ffde7566766 - rustc_mir_transform[df85c3740367f631]::deduce_param_attrs::deduced_param_attrs
  41:     0x7ffde75630f3 - rustc_mir_transform[df85c3740367f631]::deduce_param_attrs::deduced_param_attrs
  42:     0x7ffde7564dd6 - rustc_mir_transform[df85c3740367f631]::deduce_param_attrs::deduced_param_attrs
  43:     0x7ffde69bdc57 - rustc_mir_transform[df85c3740367f631]::is_mir_available
  44:     0x7ffde69b554f - rustc_mir_transform[df85c3740367f631]::shim::make_shim
  45:     0x7ffde6c6e126 - <alloc[5ee769a2c16ffbe5]::sync::Arc<rustc_session[3b6e91cc442c9304]::config::OutputFilenames>>::drop_slow
  46:     0x7ffde6c53793 - <alloc[5ee769a2c16ffbe5]::sync::Arc<rustc_session[3b6e91cc442c9304]::config::OutputFilenames>>::drop_slow
  47:     0x7ffde6bbfc83 - RINvNtNtCs1k3oNJgFkWS_18rustc_query_system5query8plumbing17try_execute_queryINtCs9yixdmdYRUZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheNtNtNtCs2WcbfYfVIWs_12rustc_middle2ty8instance12InstanceKindINtNtNtB2z_5query5erase6ErasedAhj8_EEKb0_
  48:     0x7ffde6c82be2 - rustc_query_impl[6f45aaa328468e93]::query_system
  49:     0x7ffde9f85a8b - <rustc_middle[223a725a3241bbc2]::ty::context::TyCtxt>::coroutine_layout
  50:     0x7ffde7e2152f - rustc_ty_utils[45a1d957d15ee6cd]::layout::layout_of
  51:     0x7ffde801dd4e - rustc_query_impl[6f45aaa328468e93]::plumbing::query_key_hash_verify_all
  52:     0x7ffde7ef7941 - RINvNtNtCs1k3oNJgFkWS_18rustc_query_system5query8plumbing17try_execute_queryINtCs9yixdmdYRUZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCs2WcbfYfVIWs_12rustc_middle2ty20PseudoCanonicalInputNtB2w_2TyEINtNtNtB2y_5query5erase6ErasedAhj
  53:     0x7ffde802c21b - rustc_query_impl[6f45aaa328468e93]::plumbing::query_key_hash_verify_all
  54:     0x7ffde7b99e1c - <rustc_mir_dataflow[afa65aad2ef5b93e]::value_analysis::Map>::new
  55:     0x7ffde8fb9b57 - <rustc_mir_transform[df85c3740367f631]::dataflow_const_prop::DataflowConstProp as rustc_mir_transform[df85c3740367f631]::pass_manager::MirPass>::run_pass
  56:     0x7ffde755fac7 - <rustc_mir_transform[df85c3740367f631]::simplify::SimplifyCfg as rustc_mir_transform[df85c3740367f631]::pass_manager::MirPass>::run_pass     
  57:     0x7ffde759163b - rustc_mir_transform[df85c3740367f631]::run_analysis_to_runtime_passes
  58:     0x7ffde7591eef - rustc_mir_transform[df85c3740367f631]::optimized_mir
  59:     0x7ffde801beb0 - rustc_query_impl[6f45aaa328468e93]::plumbing::query_key_hash_verify_all
  60:     0x7ffde7ee7a1b - RINvNtNtCs1k3oNJgFkWS_18rustc_query_system5query8plumbing17try_execute_queryINtCs9yixdmdYRUZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches10DefIdCacheINtNtNtCs2WcbfYfVIWs_12rustc_middle5query5erase6ErasedAhj8_EEKb0_KB3r_KB3r_ENtNtB1f_8plumbing9QueryCtxt
  61:     0x7ffde80223c4 - rustc_query_impl[6f45aaa328468e93]::plumbing::query_key_hash_verify_all
  62:     0x7ffde9f85eab - <rustc_middle[223a725a3241bbc2]::ty::context::TyCtxt>::coroutine_layout
  63:     0x7ffde7e2152f - rustc_ty_utils[45a1d957d15ee6cd]::layout::layout_of
  64:     0x7ffde801dd4e - rustc_query_impl[6f45aaa328468e93]::plumbing::query_key_hash_verify_all
  65:     0x7ffde7ef7941 - RINvNtNtCs1k3oNJgFkWS_18rustc_query_system5query8plumbing17try_execute_queryINtCs9yixdmdYRUZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCs2WcbfYfVIWs_12rustc_middle2ty20PseudoCanonicalInputNtB2w_2TyEINtNtNtB2y_5query5erase6ErasedAhj
  66:     0x7ffde802c21b - rustc_query_impl[6f45aaa328468e93]::plumbing::query_key_hash_verify_all
  67:     0x7ffde75f0bea - <rustc_mir_transform[df85c3740367f631]::known_panics_lint::KnownPanicsLint as rustc_mir_transform[df85c3740367f631]::pass_manager::MirLint>::run_lint
  68:     0x7ffde758cf5a - rustc_mir_transform[df85c3740367f631]::run_analysis_to_runtime_passes
  69:     0x7ffde7588d4a - rustc_mir_transform[df85c3740367f631]::mir_drops_elaborated_and_const_checked
  70:     0x7ffde801d85b - rustc_query_impl[6f45aaa328468e93]::plumbing::query_key_hash_verify_all
  71:     0x7ffde7f5ccdb - RINvNtNtCs1k3oNJgFkWS_18rustc_query_system5query8plumbing17try_execute_queryINtCs9yixdmdYRUZ_16rustc_query_impl13DynamicConfigINtNtCs7G8HGJy4UT9_21rustc_data_structures9vec_cache8VecCacheNtNtCsejbV3oEDgwb_10rustc_span6def_id10LocalDefIdINtNtNtCs2WcbfYfVIWs
  72:     0x7ffde80220c2 - rustc_query_impl[6f45aaa328468e93]::plumbing::query_key_hash_verify_all
  73:     0x7ffde7159f14 - rustc_interface[f74e78c6a24d3dfd]::passes::resolver_for_lowering_raw
  74:     0x7ffde3a643d7 - rustc_interface[f74e78c6a24d3dfd]::passes::analysis
  75:     0x7ffde6c6dcca - <alloc[5ee769a2c16ffbe5]::sync::Arc<rustc_session[3b6e91cc442c9304]::config::OutputFilenames>>::drop_slow
  76:     0x7ffde6b76e9e - RINvNtNtCs1k3oNJgFkWS_18rustc_query_system5query8plumbing17try_execute_queryINtCs9yixdmdYRUZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCs2WcbfYfVIWs_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
  77:     0x7ffde6c73db3 - rustc_query_impl[6f45aaa328468e93]::query_system
  78:     0x7ffde3a1e02f - std[9e42655e6e0f329a]::sys::backtrace::__rust_begin_short_backtrace::<<std[9e42655e6e0f329a]::thread::Builder>::spawn_unchecked_<ctrlc[869e659078d012e0]::set_handler_inner<rustc_driver_impl[ece5ca0082575a16]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>   
  79:     0x7ffde3a17f88 - std[9e42655e6e0f329a]::sys::backtrace::__rust_begin_short_backtrace::<<std[9e42655e6e0f329a]::thread::Builder>::spawn_unchecked_<ctrlc[869e659078d012e0]::set_handler_inner<rustc_driver_impl[ece5ca0082575a16]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>   
  80:     0x7ffde3a13830 - RINvNtNtCsdAptkrAWEuA_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCslepdXI2wPSX_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCskl01Gqil8UI_17rustc_driver_i
  81:     0x7ffde3a22380 - std[9e42655e6e0f329a]::sys::backtrace::__rust_begin_short_backtrace::<<std[9e42655e6e0f329a]::thread::Builder>::spawn_unchecked_<ctrlc[869e659078d012e0]::set_handler_inner<rustc_driver_impl[ece5ca0082575a16]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>   
  82:     0x7ffde70f225d - alloc::boxed::impl$28::call_once
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\alloc\src\boxed.rs:1966
  83:     0x7ffde70f225d - alloc::boxed::impl$28::call_once
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\alloc\src\boxed.rs:1966
  84:     0x7ffde70f225d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/25cdf1f67463c9365d8d83778c933ec7480e940b/library\std\src\sys\pal\windows\thread.rs:56
  85:     0x7ffec0397374 - BaseThreadInitThunk
  86:     0x7ffec0c5cc91 - RtlUserThreadStart

error: the compiler unexpectedly panicked. this is a bug.

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: compiler flags: -Z mir-opt-level=3

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `[core::mem::maybe_uninit::MaybeUninit<&[i32]>; N]: core::marker::Copy`
#1 [is_copy_raw] computing whether `[core::mem::maybe_uninit::MaybeUninit<&[i32]>; N]` is `Copy`
... and 7 other queries... use `env RUST_BACKTRACE=1` to see the full query stack

@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 Apr 29, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 29, 2025
@moxian
Copy link
Contributor

moxian commented Apr 29, 2025

Reproducible with rustc -Zmir-enable-passes=+DataflowConstProp
Bisects to #123948
@rustbot label: +A-async-await +A-const-prop +S-has-mcve +S-has-bisection -needs-triage +F-async_drop +requires-incomplete-features

@rustbot rustbot added A-async-await Area: Async & Await A-const-prop Area: Constant propagation F-async_drop Async drop S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue requires-incomplete-features This issue requires the use of incomplete features. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-const-prop Area: Constant propagation C-bug Category: This is a bug. F-async_drop Async drop I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features This issue requires the use of incomplete features. S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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

3 participants