Skip to content

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

Closed
@sososopy

Description

@sososopy

Possible repetition with #129209

Code

async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone {
    func(iter.map(|x| x + 1))
}
fn main() {}

Meta

rustc --version --verbose:

rustc 1.88.0-nightly (d5b4c2e4f 2025-04-02)
binary: rustc
commit-hash: d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df
commit-date: 2025-04-02
host: x86_64-pc-windows-msvc
release: 1.88.0-nightly
LLVM version: 20.1.1

Error output

error[E0670]: `async fn` is not permitted in Rust 2015
   --> .\ttt\test.rs:223:1
    |
223 | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone {
    | ^^^^^ to use `async fn`, switch to Rust 2018 or later
    |
    = help: pass `--edition 2024` to `rustc`
    = note: for more on editions, read https://doc.rust-lang.org/edition-guide

error[E0277]: the trait bound `Map<T, {closure@.\ttt\test.rs:224:19: 224:22}>: Copy` is not satisfied
   --> .\ttt\test.rs:224:10
    |
224 |     func(iter.map(|x| x + 1))
    |     ---- ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Map<T, {closure@.\ttt\test.rs:224:19: 224:22}>`
    |     |
    |     required by a bound introduced by this call
    |
note: required by a bound in `func`
   --> .\ttt\test.rs:223:40
    |
223 | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone {
    |                                        ^^^^ required by this bound in `func`
help: consider removing this method call, as the receiver has type `T` and `T: Copy` trivially holds
    |
224 -     func(iter.map(|x| x + 1))
224 +     func(iter)
    |

error[E0277]: the trait bound `Map<T, {closure@.\ttt\test.rs:224:19: 224:22}>: Copy` is not satisfied
   --> .\ttt\test.rs:224:5
    |
224 |     func(iter.map(|x| x + 1))
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Map<T, {closure@.\ttt\test.rs:224:19: 224:22}>`
Backtrace

thread 'rustc' panicked at compiler\rustc_middle\src\ty\sty.rs:361:36:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7ff94dd65272 - std::backtrace_rs::backtrace::win64::trace
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
   1:     0x7ff94dd65272 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff94dd65272 - std::sys::backtrace::_print_fmt
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\std\src\sys\backtrace.rs:66
   3:     0x7ff94dd65272 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\std\src\sys\backtrace.rs:39
   4:     0x7ff94dd9757b - core::fmt::rt::Argument::fmt
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\core\src\fmt\rt.rs:178
   5:     0x7ff94dd9757b - core::fmt::write
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\core\src\fmt\mod.rs:1480
   6:     0x7ff94dd5b577 - std::io::default_write_fmt
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\std\src\io\mod.rs:639
   7:     0x7ff94dd5b577 - std::io::Write::write_fmt<std::sys::stdio::windows::Stderr>
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\std\src\io\mod.rs:1914
   8:     0x7ff94dd650b5 - std::sys::backtrace::BacktraceLock::print
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\std\src\sys\backtrace.rs:42
   9:     0x7ff94dd6bf7a - std::panicking::default_hook::closure$0
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\std\src\panicking.rs:300
  10:     0x7ff94dd6bd10 - std::panicking::default_hook
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\std\src\panicking.rs:327
  11:     0x7ff94f432427 - core[dc542ccc761a93d1]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[c80db952a9a9e479]::Level, &str), usize), <((rustc_lint_defs[c80db952a9a9e479]::Level, &str), usize) as core[dc542ccc761a93d1]::cmp::PartialOrd>::lt>
  12:     0x7ff94dd6cc0e - std::panicking::rust_panic_with_hook
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\std\src\panicking.rs:841
  13:     0x7ff94dd6c932 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\std\src\panicking.rs:699
  14:     0x7ff94dd6603f - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\std\src\sys\backtrace.rs:168
  15:     0x7ff94dd6c56e - std::panicking::begin_panic_handler
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\std\src\panicking.rs:697
  16:     0x7ff950e423f1 - core::panicking::panic_fmt
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\core\src\panicking.rs:75
  17:     0x7ff950e424ad - core::panicking::panic
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\core\src\panicking.rs:145
  18:     0x7ff950e4236e - core::option::unwrap_failed
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\core\src\option.rs:2015
  19:     0x7ff94dbf83f6 - <rustc_middle[5fb3d1e7f89237ca]::ty::sty::ParamConst>::find_ty_from_env
  20:     0x7ff94ed35baa - <rustc_trait_selection[469af7cfce058518]::traits::fulfill::FulfillProcessor as rustc_data_structures[d5b917962fc811cd]::obligation_forest::ObligationProcessor>::process_obligation
  21:     0x7ff94ec96d17 - <rustc_data_structures[d5b917962fc811cd]::obligation_forest::ObligationForest<rustc_trait_selection[469af7cfce058518]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[469af7cfce058518]::traits::fulfill::FulfillProcessor>
  22:     0x7ff94ece7d6f - <rustc_trait_selection[469af7cfce058518]::traits::engine::ObligationCtxt<rustc_trait_selection[469af7cfce058518]::traits::FulfillmentError>>::assumed_wf_types_and_report_errors
  23:     0x7ff95076e656 - <rustc_middle[5fb3d1e7f89237ca]::traits::ObligationCause as rustc_trait_selection[469af7cfce058518]::error_reporting::infer::ObligationCauseExt>::as_failure_code_diag
  24:     0x7ff950728e7f - <rustc_trait_selection[469af7cfce058518]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
  25:     0x7ff94dfe98e7 - rustc_hir_typeck[29b22c12492aea0f]::typeck
  26:     0x7ff94defac95 - <<rustc_hir_typeck[29b22c12492aea0f]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[e8f4e585c828fe5e]::visit::TypeVisitor<rustc_middle[5fb3d1e7f89237ca]::ty::context::TyCtxt>>::visit_ty
  27:     0x7ff94defeabb - <<rustc_hir_typeck[29b22c12492aea0f]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[e8f4e585c828fe5e]::visit::TypeVisitor<rustc_middle[5fb3d1e7f89237ca]::ty::context::TyCtxt>>::visit_ty
  28:     0x7ff94df5fa82 - <<rustc_hir_typeck[29b22c12492aea0f]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[e8f4e585c828fe5e]::visit::TypeVisitor<rustc_middle[5fb3d1e7f89237ca]::ty::context::TyCtxt>>::visit_ty
  29:     0x7ff94defccea - <<rustc_hir_typeck[29b22c12492aea0f]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[e8f4e585c828fe5e]::visit::TypeVisitor<rustc_middle[5fb3d1e7f89237ca]::ty::context::TyCtxt>>::visit_ty
  30:     0x7ff94dfba132 - rustc_hir_typeck[29b22c12492aea0f]::typeck
  31:     0x7ff94dfbe665 - rustc_hir_typeck[29b22c12492aea0f]::typeck
  32:     0x7ff94df00fcb - <<rustc_hir_typeck[29b22c12492aea0f]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[e8f4e585c828fe5e]::visit::TypeVisitor<rustc_middle[5fb3d1e7f89237ca]::ty::context::TyCtxt>>::visit_ty
  33:     0x7ff94dfba132 - rustc_hir_typeck[29b22c12492aea0f]::typeck
  34:     0x7ff94e00bdca - <rustc_hir_typeck[29b22c12492aea0f]::upvar::InferBorrowKind as rustc_hir_typeck[29b22c12492aea0f]::expr_use_visitor::Delegate>::borrow
  35:     0x7ff94dfb978f - rustc_hir_typeck[29b22c12492aea0f]::typeck
  36:     0x7ff94ec48ccb - rustc_query_impl[d9335ea94c0b0ece]::plumbing::query_key_hash_verify_all
  37:     0x7ff94eb872bb - RINvNtNtCskvioGLgoOG9_18rustc_query_system5query8plumbing17try_execute_queryINtCsiE9y6tCaNS4_16rustc_query_impl13DynamicConfigINtNtCsilDQ9z9nh3l_21rustc_data_structures9vec_cache8VecCacheNtNtCs4tKXlikXsF2_10rustc_span6def_id10LocalDefIdINtNtNtCs8dq9bBHR3kY
  38:     0x7ff94ec51212 - rustc_query_impl[d9335ea94c0b0ece]::plumbing::query_key_hash_verify_all
  39:     0x7ff94d5a862c - <rustc_hir_analysis[653cc36538c3ef1]::collect::type_of::opaque::RpitConstraintChecker as rustc_hir[54d9011b315e8a82]::intravisit::Visitor>::visit_expr
  40:     0x7ff94d8e779b - <alloc[b8a61deb1be72a43]::sync::Arc<rustc_session[15763e0c540e77d7]::cstore::CrateSource>>::drop_slow
  41:     0x7ff94eb12e0b - RINvNtNtCskvioGLgoOG9_18rustc_query_system5query8plumbing17try_execute_queryINtCsiE9y6tCaNS4_16rustc_query_impl13DynamicConfigINtNtB4_6caches10DefIdCacheINtNtNtCs8dq9bBHR3kY_12rustc_middle5query5erase6ErasedAhj8_EEKb0_KB3r_KB3r_ENtNtB1f_8plumbing9QueryCtxt
  42:     0x7ff94d8f0d54 - rustc_query_impl[d9335ea94c0b0ece]::query_system
  43:     0x7ff94e0bb442 - <rustc_hir_analysis[653cc36538c3ef1]::collect::resolve_bound_vars::is_late_bound_map::ConstrainedCollector as rustc_hir[54d9011b315e8a82]::intravisit::Visitor>::visit_ty
  44:     0x7ff94ec48d00 - rustc_query_impl[d9335ea94c0b0ece]::plumbing::query_key_hash_verify_all
  45:     0x7ff94eb12e0b - RINvNtNtCskvioGLgoOG9_18rustc_query_system5query8plumbing17try_execute_queryINtCsiE9y6tCaNS4_16rustc_query_impl13DynamicConfigINtNtB4_6caches10DefIdCacheINtNtNtCs8dq9bBHR3kY_12rustc_middle5query5erase6ErasedAhj8_EEKb0_KB3r_KB3r_ENtNtB1f_8plumbing9QueryCtxt
  46:     0x7ff94ec4ad76 - rustc_query_impl[d9335ea94c0b0ece]::plumbing::query_key_hash_verify_all
  47:     0x7ff94d583825 - rustc_hir_analysis[653cc36538c3ef1]::check::check::check_abi_fn_ptr
  48:     0x7ff94e083fc8 - rustc_hir_analysis[653cc36538c3ef1]::check::wfcheck::check_well_formed
  49:     0x7ff94ec4788b - rustc_query_impl[d9335ea94c0b0ece]::plumbing::query_key_hash_verify_all
  50:     0x7ff94eb80f33 - RINvNtNtCskvioGLgoOG9_18rustc_query_system5query8plumbing17try_execute_queryINtCsiE9y6tCaNS4_16rustc_query_impl13DynamicConfigINtNtCsilDQ9z9nh3l_21rustc_data_structures9vec_cache8VecCacheNtNtCs4tKXlikXsF2_10rustc_span6def_id10LocalDefIdINtNtNtCs8dq9bBHR3kY
  51:     0x7ff94ec583b5 - rustc_query_impl[d9335ea94c0b0ece]::plumbing::query_key_hash_verify_all
  52:     0x7ff94e0941d2 - rustc_hir_analysis[653cc36538c3ef1]::check::wfcheck::check_mod_type_wf
  53:     0x7ff94d8e886b - <alloc[b8a61deb1be72a43]::sync::Arc<rustc_session[15763e0c540e77d7]::cstore::CrateSource>>::drop_slow
  54:     0x7ff94d8334cc - RINvNtNtCskvioGLgoOG9_18rustc_query_system5query8plumbing17try_execute_queryINtCsiE9y6tCaNS4_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheNtNtCs4tKXlikXsF2_10rustc_span6def_id13LocalModDefIdINtNtNtCs8dq9bBHR3kY_12rustc_middle5query5erase6E
  55:     0x7ff94d8fc730 - rustc_query_impl[d9335ea94c0b0ece]::query_system
  56:     0x7ff94e0ddb2a - rustc_hir_analysis[653cc36538c3ef1]::check_crate
  57:     0x7ff94ddd499f - rustc_interface[cabc4d9db40f56f8]::passes::resolver_for_lowering_raw
  58:     0x7ff94a6d6697 - rustc_interface[cabc4d9db40f56f8]::passes::analysis
  59:     0x7ff94d8eb64a - <alloc[b8a61deb1be72a43]::sync::Arc<rustc_session[15763e0c540e77d7]::cstore::CrateSource>>::drop_slow
  60:     0x7ff94d7f3ece - RINvNtNtCskvioGLgoOG9_18rustc_query_system5query8plumbing17try_execute_queryINtCsiE9y6tCaNS4_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCs8dq9bBHR3kY_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
  61:     0x7ff94d8f18b3 - rustc_query_impl[d9335ea94c0b0ece]::query_system
  62:     0x7ff94a69a10f - RINvNtNtCsi2E9fhZYu8g_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCsfQSFmXOyJZn_5alloc5boxed3BoxDINtNtNtCsiUNUIDks29p_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECs7V8
  63:     0x7ff94a694043 - RINvNtNtCsi2E9fhZYu8g_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCsfQSFmXOyJZn_5alloc5boxed3BoxDINtNtNtCsiUNUIDks29p_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECs7V8
  64:     0x7ff94a68ed13 - RINvNtNtCsi2E9fhZYu8g_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCshp9I49agxXE_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCs7V8n164MtzI_17rustc_driver_i
  65:     0x7ff94a69e6f0 - RINvNtNtCsi2E9fhZYu8g_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCsfQSFmXOyJZn_5alloc5boxed3BoxDINtNtNtCsiUNUIDks29p_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECs7V8
  66:     0x7ff94dd7192d - alloc::boxed::impl$28::call_once
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\alloc\src\boxed.rs:1966
  67:     0x7ff94dd7192d - alloc::boxed::impl$28::call_once
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\alloc\src\boxed.rs:1966
  68:     0x7ff94dd7192d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/d5b4c2e4f19b6d7037371cdaecc3cc2c701c68df/library\std\src\sys\pal\windows\thread.rs:56
  69:     0x7ffa233b7374 - BaseThreadInitThunk
  70:     0x7ffa23f3cc91 - 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: 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-04-03T11_08_32-37624.txt` to your bug report

query stack during panic:
#0 [typeck] type-checking `func`
#1 [type_of_opaque] computing type of opaque `func::{opaque#0}`
... and 4 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: aborting due to 3 previous errors

Metadata

Metadata

Labels

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