Skip to content
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

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

Closed
Naserume opened this issue May 23, 2024 · 2 comments · Fixed by #125466
Assignees
Labels
A-type-system Area: Type system C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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

@Naserume
Copy link

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.

@Naserume Naserume 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 May 23, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 23, 2024
@jieyouxu jieyouxu added A-type-system Area: Type system S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 23, 2024
@jieyouxu
Copy link
Member

********************************************************************************
Regression in nightly-2022-10-07
********************************************************************************

fetching https://static.rust-lang.org/dist/2022-10-06/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2022-10-06: 40 B / 40 B [==========================================================================================================================================================================================================================================================] 100.00 % 293.37 KB/s converted 2022-10-06 to c97d02cdb5ca5f5e9eff1fa9e4560d220d1fd2a0
fetching https://static.rust-lang.org/dist/2022-10-07/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2022-10-07: 40 B / 40 B [==========================================================================================================================================================================================================================================================] 100.00 % 846.96 KB/s converted 2022-10-07 to 0ca356586fed56002b10920fd21ddf6fb12de797
looking for regression commit between 2022-10-06 and 2022-10-07
fetching (via remote github) commits from max(c97d02cdb5ca5f5e9eff1fa9e4560d220d1fd2a0, 2022-10-04) to 0ca356586fed56002b10920fd21ddf6fb12de797
ending github query because we found starting sha: c97d02cdb5ca5f5e9eff1fa9e4560d220d1fd2a0
get_commits_between returning commits, len: 7
  commit[0] 2022-10-05: Auto merge of #102394 - dingxiangfei2009:issue-102317, r=oli-obk
  commit[1] 2022-10-06: Auto merge of #102573 - RalfJung:mirisync, r=oli-obk
  commit[2] 2022-10-06: Auto merge of #99324 - reez12g:issue-99144, r=jyn514
  commit[3] 2022-10-06: Auto merge of #102726 - matthiaskrgr:rollup-2ghn38b, r=matthiaskrgr
  commit[4] 2022-10-06: Auto merge of #102707 - fmease:rustdoc-render-more-cross-crate-hrtbs-properly, r=GuillaumeGomez
  commit[5] 2022-10-06: Auto merge of #99497 - vladimir-ea:stdlib_os_api_watchos, r=thomcc
  commit[6] 2022-10-06: Auto merge of #102741 - matthiaskrgr:rollup-63no5tz, r=matthiaskrgr
ERROR: no CI builds available between c97d02cdb5ca5f5e9eff1fa9e4560d220d1fd2a0 and 0ca356586fed56002b10920fd21ddf6fb12de797 within last 167 days

@jieyouxu
Copy link
Member

Maybe #102694 but probably easier to debug from scratch.

@compiler-errors compiler-errors self-assigned this May 23, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this issue May 26, 2024
…ig-in-sugg, r=jieyouxu

Don't continue probing for method if in suggestion and autoderef hits ambiguity

The title is somewhat self-explanatory. When we hit ambiguity in method autoderef steps, we previously would continue to probe for methods if we were giving a suggestion. This seems useless, and causes an ICE when we are not able to unify the receiver later on in confirmation.

Fixes rust-lang#125432
jhpratt added a commit to jhpratt/rust that referenced this issue May 26, 2024
…ig-in-sugg, r=jieyouxu

Don't continue probing for method if in suggestion and autoderef hits ambiguity

The title is somewhat self-explanatory. When we hit ambiguity in method autoderef steps, we previously would continue to probe for methods if we were giving a suggestion. This seems useless, and causes an ICE when we are not able to unify the receiver later on in confirmation.

Fixes rust-lang#125432
@bors bors closed this as completed in 09e7592 May 27, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 27, 2024
Rollup merge of rust-lang#125466 - compiler-errors:dont-probe-for-ambig-in-sugg, r=jieyouxu

Don't continue probing for method if in suggestion and autoderef hits ambiguity

The title is somewhat self-explanatory. When we hit ambiguity in method autoderef steps, we previously would continue to probe for methods if we were giving a suggestion. This seems useless, and causes an ICE when we are not able to unify the receiver later on in confirmation.

Fixes rust-lang#125432
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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

Successfully merging a pull request may close this issue.

4 participants