Skip to content

ICE : called Option::unwrap() on a None value in compiler/rustc_hir_typeck/src/method/confirm.rs #125432

Closed
@Naserume

Description

@Naserume

Code

fn separate_arms() {
    // Here both arms perform assignments, but only one is illegal.

    let mut x = None;
    match x {
        None => {
            // It is ok to reassign x here, because there is in
            // fact no outstanding loan of x!
            x = Some(0);
        }
        Some(right) => consume(right),
    }
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.80.0-nightly (9cdfe285c 2024-05-22)
binary: rustc
commit-hash: 9cdfe285ca724c801dc9f78d22b24ea69b787f26
commit-date: 2024-05-22
host: x86_64-apple-darwin
release: 1.80.0-nightly
LLVM version: 18.1.6

Error output

ERROR rustc_hir_typeck::method::confirm {integer} was a subtype of &mut _ but now is not?
thread 'rustc' panicked at compiler/rustc_hir_typeck/src/method/confirm.rs:518:45:
called `Option::unwrap()` on a `None` value
Backtrace

stack backtrace:
   0:        0x10bfa42f3 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8c13c3958f9af8aa
   1:        0x10bfef9fb - core::fmt::write::h8f6df19365b02c63
   2:        0x10bf9a4fe - std::io::Write::write_fmt::hf76a03cffc843394
   3:        0x10bfa40e1 - std::sys_common::backtrace::print::h65db49fb68c63f65
   4:        0x10bfa6e99 - std::panicking::default_hook::{{closure}}::hb8f56e4e2b8f1bf2
   5:        0x10bfa6be0 - std::panicking::default_hook::h3a63270fb79f05e7
   6:        0x114ce323c - std[46b01aaf7e2caa06]::panicking::update_hook::<alloc[59a7021da80c39d9]::boxed::Box<rustc_driver_impl[8eb753b65fc6833d]::install_ice_hook::{closure#0}>>::{closure#0}
   7:        0x10bfa79a3 - std::panicking::rust_panic_with_hook::h54095a093db9b329
   8:        0x10bfa72aa - std::panicking::begin_panic_handler::{{closure}}::h857a5af4d92e8a99
   9:        0x10bfa47c9 - std::sys_common::backtrace::__rust_end_short_backtrace::h23279e783e012d48
  10:        0x10bfa7016 - _rust_begin_unwind
  11:        0x10c00c072 - core::panicking::panic_fmt::hab9c0a7d422b7fc9
  12:        0x10c00c134 - core::panicking::panic::h90c11d1116a411b4
  13:        0x10c00c018 - core::option::unwrap_failed::h8de19aabfc4104a1
  14:        0x1151e1b3e - <rustc_hir_typeck[b11ff548edcbb4a5]::method::confirm::ConfirmContext>::confirm
  15:        0x115169ba0 - <rustc_hir_typeck[b11ff548edcbb4a5]::fn_ctxt::FnCtxt>::confirm_builtin_call
  16:        0x1152672a3 - <rustc_hir_typeck[b11ff548edcbb4a5]::fn_ctxt::FnCtxt>::check_expr_kind
  17:        0x11518a7eb - <rustc_hir_typeck[b11ff548edcbb4a5]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  18:        0x11526478f - <rustc_hir_typeck[b11ff548edcbb4a5]::fn_ctxt::FnCtxt>::check_expr_kind
  19:        0x11518a7eb - <rustc_hir_typeck[b11ff548edcbb4a5]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20:        0x1151c8730 - <rustc_hir_typeck[b11ff548edcbb4a5]::fn_ctxt::FnCtxt>::check_block_with_expected
  21:        0x11518a7eb - <rustc_hir_typeck[b11ff548edcbb4a5]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  22:        0x11518c694 - <rustc_hir_typeck[b11ff548edcbb4a5]::fn_ctxt::FnCtxt>::check_return_expr
  23:        0x11524b110 - rustc_hir_typeck[b11ff548edcbb4a5]::check::check_fn
  24:        0x1152434a1 - rustc_hir_typeck[b11ff548edcbb4a5]::typeck
  25:        0x11619305a - rustc_query_impl[10f139cddafaeae9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[10f139cddafaeae9]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[10991ae1fad52f46]::query::erase::Erased<[u8; 8usize]>>
  26:        0x116016e07 - rustc_query_system[78cc7b52ad177976]::query::plumbing::try_execute_query::<rustc_query_impl[10f139cddafaeae9]::DynamicConfig<rustc_query_system[78cc7b52ad177976]::query::caches::VecCache<rustc_span[293d940ddba48bf9]::def_id::LocalDefId, rustc_middle[10991ae1fad52f46]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[10f139cddafaeae9]::plumbing::QueryCtxt, false>
  27:        0x1161b55db - rustc_query_impl[10f139cddafaeae9]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  28:        0x114f2c20e - <rustc_middle[10991ae1fad52f46]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[def2e50b3113a2e2]::check_crate::{closure#4}>::{closure#0}
  29:        0x11503addc - rustc_hir_analysis[def2e50b3113a2e2]::check_crate
  30:        0x1154c4091 - rustc_interface[80562b29f4e45c6d]::passes::run_required_analyses
  31:        0x1154c66d3 - rustc_interface[80562b29f4e45c6d]::passes::analysis
  32:        0x1161930aa - rustc_query_impl[10f139cddafaeae9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[10f139cddafaeae9]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[10991ae1fad52f46]::query::erase::Erased<[u8; 1usize]>>
  33:        0x115f70ede - rustc_query_system[78cc7b52ad177976]::query::plumbing::try_execute_query::<rustc_query_impl[10f139cddafaeae9]::DynamicConfig<rustc_query_system[78cc7b52ad177976]::query::caches::SingleCache<rustc_middle[10991ae1fad52f46]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[10f139cddafaeae9]::plumbing::QueryCtxt, false>
  34:        0x11619d287 - rustc_query_impl[10f139cddafaeae9]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:        0x114c93547 - <rustc_interface[80562b29f4e45c6d]::queries::QueryResult<&rustc_middle[10991ae1fad52f46]::ty::context::GlobalCtxt>>::enter::<core[d803bfff9fdc95aa]::result::Result<(), rustc_span[293d940ddba48bf9]::ErrorGuaranteed>, rustc_driver_impl[8eb753b65fc6833d]::run_compiler::{closure#0}::{closure#1}::{closure#3}>
  36:        0x114cea40d - rustc_interface[80562b29f4e45c6d]::interface::run_compiler::<core[d803bfff9fdc95aa]::result::Result<(), rustc_span[293d940ddba48bf9]::ErrorGuaranteed>, rustc_driver_impl[8eb753b65fc6833d]::run_compiler::{closure#0}>::{closure#1}
  37:        0x114cd85a1 - std[46b01aaf7e2caa06]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[80562b29f4e45c6d]::util::run_in_thread_with_globals<rustc_interface[80562b29f4e45c6d]::util::run_in_thread_pool_with_globals<rustc_interface[80562b29f4e45c6d]::interface::run_compiler<core[d803bfff9fdc95aa]::result::Result<(), rustc_span[293d940ddba48bf9]::ErrorGuaranteed>, rustc_driver_impl[8eb753b65fc6833d]::run_compiler::{closure#0}>::{closure#1}, core[d803bfff9fdc95aa]::result::Result<(), rustc_span[293d940ddba48bf9]::ErrorGuaranteed>>::{closure#0}, core[d803bfff9fdc95aa]::result::Result<(), rustc_span[293d940ddba48bf9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d803bfff9fdc95aa]::result::Result<(), rustc_span[293d940ddba48bf9]::ErrorGuaranteed>>
  38:        0x114cf11b6 - <<std[46b01aaf7e2caa06]::thread::Builder>::spawn_unchecked_<rustc_interface[80562b29f4e45c6d]::util::run_in_thread_with_globals<rustc_interface[80562b29f4e45c6d]::util::run_in_thread_pool_with_globals<rustc_interface[80562b29f4e45c6d]::interface::run_compiler<core[d803bfff9fdc95aa]::result::Result<(), rustc_span[293d940ddba48bf9]::ErrorGuaranteed>, rustc_driver_impl[8eb753b65fc6833d]::run_compiler::{closure#0}>::{closure#1}, core[d803bfff9fdc95aa]::result::Result<(), rustc_span[293d940ddba48bf9]::ErrorGuaranteed>>::{closure#0}, core[d803bfff9fdc95aa]::result::Result<(), rustc_span[293d940ddba48bf9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d803bfff9fdc95aa]::result::Result<(), rustc_span[293d940ddba48bf9]::ErrorGuaranteed>>::{closure#2} as core[d803bfff9fdc95aa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:        0x10bfb105b - std::sys::pal::unix::thread::Thread::new::thread_start::h08bab28ee5f6d93f
  40:     0x7ff801f5318b - __pthread_start

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 `/Users/Documents/rustc-ice-2024-05-23T02_06_33-18540.txt` to your bug report

query stack during panic:
#0 [typeck] type-checking `separate_arms`
#1 [analysis] running analysis passes on this crate
end of query stack
note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: stashing CallIntoMethod
  --> 5AF09F7CE201B3A68413D878FA74FBB32B43F74B58E536642D6CE182A0DF5212.rs:11:24
   |
11 |         Some(right) => consume(right),
   |                        ^^^^^^^
   |
note: delayed at compiler/rustc_errors/src/lib.rs:778:32 - disabled backtrace
  --> 5AF09F7CE201B3A68413D878FA74FBB32B43F74B58E536642D6CE182A0DF5212.rs:11:24
   |
11 |         Some(right) => consume(right),
   |                        ^^^^^^^

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 `/Users/Documents/rustc-ice-2024-05-23T02_06_33-18540.txt` to your bug report

query stack during panic:
end of query stack
thread 'rustc' panicked at library/core/src/panicking.rs:227:5:
panic in a destructor during cleanup

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 `/Users/Documents/rustc-ice-2024-05-23T02_06_33-18540.txt` to your bug report

query stack during panic:
end of query stack
thread caused non-unwinding panic. aborting.

Metadata

Metadata

Labels

A-type-systemArea: Type systemC-bugCategory: This is a bug.E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustcI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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