rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.01k stars 12.54k forks source link

ICE: already mutably borrowed: BorrowError - compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs:1755 #117456

Closed irevoire closed 10 months ago

irevoire commented 10 months ago

Hey, really sorry, I don't have the time at all to try to minimize the code, the code base is so large and I’m really in a rush 😢

BUT, I do reproduce the error on my computer after a cargo clean, which means you should be able to reproduce it as well. I ran cargo check on this commit: https://github.com/meilisearch/meilisearch/pull/3971/commits/03b510945b751d433bdc513c99b824d1ea40a45b

Code

In a match:

Err(e) => return Err(e.into()),

Meta

rustc --version --verbose:

rustc 1.75.0-nightly (df871fbf0 2023-10-24)
binary: rustc
commit-hash: df871fbf053de3a855398964cd05fadbe91cf4fd
commit-date: 2023-10-24
host: aarch64-apple-darwin
release: 1.75.0-nightly
LLVM version: 17.0.3

It doesn't reproduce on stable.

Error output

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs:1755:62:
already mutably borrowed: BorrowError
Backtrace

``` stack backtrace: 0: _rust_begin_unwind 1: core::panicking::panic_fmt 2: core::cell::panic_already_mutably_borrowed 3: ::suggest_missing_unwrap_expect 4: ::emit_type_mismatch_suggestions 5: ::emit_coerce_suggestions 6: >::coerce_inner::<>::coerce::{closure#0}> 7: ::check_return_expr 8: ::check_expr_kind 9: ::check_expr_with_expectation_and_args 10: ::check_match 11: ::check_expr_kind 12: ::check_expr_with_expectation_and_args 13: ::check_stmt 14: ::check_block_with_expected 15: ::check_expr_with_expectation_and_args 16: ::check_match 17: ::check_expr_kind 18: ::check_expr_with_expectation_and_args 19: ::check_decl_initializer 20: ::check_decl 21: ::check_stmt 22: ::check_block_with_expected 23: ::check_expr_with_expectation_and_args 24: ::check_return_expr 25: rustc_hir_typeck::check::check_fn 26: rustc_hir_typeck::typeck [... omitted 2 frames ...] 27: std::panicking::try::<(), core::panic::unwind_safe::AssertUnwindSafe::par_body_owners::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>> 28: rustc_data_structures::sync::parallel::disabled::par_for_each_in::<&[rustc_span::def_id::LocalDefId], ::par_body_owners::{closure#0}> 29: rustc_hir_analysis::check_crate 30: rustc_interface::passes::analysis [... omitted 2 frames ...] 31: ::enter::> 32: rustc_span::set_source_map::, rustc_interface::interface::run_compiler, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}> note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. 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 attach the file at `/Users/irevoire/MeiliSearch/rustc-ice-2023-10-31T16_52_11-41833.txt` to your bug report note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED] note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [typeck] type-checking `::run` #1 [analysis] running analysis passes on this crate end of query stack error: internal compiler error: no errors encountered even though `delay_span_bug` issued error: internal compiler error: coercion error but no error emitted --> index-scheduler/src/lib.rs:462:38 | 462 | Err(e) => return Err(e.into()), | ^^^^^^^^^^^^^ | note: delayed at compiler/rustc_hir_typeck/src/coercion.rs:1575:34 0: std::backtrace::Backtrace::create 1: ::emit_diagnostic 2: ::delay_span_bug:: 3: >::coerce_inner::<>::coerce::{closure#0}> 4: ::check_return_expr 5: ::check_expr_kind 6: ::check_expr_with_expectation_and_args 7: ::check_match 8: ::check_expr_kind 9: ::check_expr_with_expectation_and_args 10: ::check_stmt 11: ::check_block_with_expected 12: ::check_expr_with_expectation_and_args 13: ::check_match 14: ::check_expr_kind 15: ::check_expr_with_expectation_and_args 16: ::check_decl_initializer 17: ::check_decl 18: ::check_stmt 19: ::check_block_with_expected 20: ::check_expr_with_expectation_and_args 21: ::check_return_expr 22: rustc_hir_typeck::check::check_fn 23: rustc_hir_typeck::typeck 24: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 25: >::call_once 26: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true> 27: rustc_query_impl::query_impl::typeck::get_query_incr::__rust_end_short_backtrace 28: std::panicking::try::<(), core::panic::unwind_safe::AssertUnwindSafe::par_body_owners::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>> 29: rustc_data_structures::sync::parallel::disabled::par_for_each_in::<&[rustc_span::def_id::LocalDefId], ::par_body_owners::{closure#0}> 30: rustc_hir_analysis::check_crate 31: rustc_interface::passes::analysis 32: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 33: >::call_once 34: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true> 35: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace 36: ::enter::> 37: rustc_span::set_source_map::, rustc_interface::interface::run_compiler, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}> 38: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 39: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 40: std::sys::unix::thread::Thread::new::thread_start 41: __pthread_deallocate --> index-scheduler/src/lib.rs:462:38 | 462 | Err(e) => return Err(e.into()), | ^^^^^^^^^^^^^ 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 attach the file at `/Users/irevoire/MeiliSearch/rustc-ice-2023-10-31T16_52_11-41833.txt` to your bug report note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED] note: some of the compiler flags provided by cargo are hidden query stack during panic: end of query stack thread 'rustc' panicked at library/core/src/panicking.rs:144: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 attach the file at `/Users/irevoire/MeiliSearch/rustc-ice-2023-10-31T16_52_11-41833.txt` to your bug report note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED] note: some of the compiler flags provided by cargo are hidden query stack during panic: end of query stack thread caused non-unwinding panic. aborting. error: could not compile `index-scheduler` (lib) Caused by: process didn't exit successfully: `/Users/irevoire/.rustup/toolchains/nightly-aarch64-apple-darwin/bin/rustc --crate-name index_scheduler --edition=2021 index-scheduler/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=181 --crate-type lib --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C metadata=59600733d24874e7 -C extra-filename=-59600733d24874e7 --out-dir /Users/irevoire/MeiliSearch/target/debug/deps -C incremental=/Users/irevoire/MeiliSearch/target/debug/incremental -L dependency=/Users/irevoire/MeiliSearch/target/debug/deps --extern anyhow=/Users/irevoire/MeiliSearch/target/debug/deps/libanyhow-c317411f8a979705.rmeta --extern bincode=/Users/irevoire/MeiliSearch/target/debug/deps/libbincode-325b2cf6dd4ebb21.rmeta --extern csv=/Users/irevoire/MeiliSearch/target/debug/deps/libcsv-6da6cbf519f1f05a.rmeta --extern derive_builder=/Users/irevoire/MeiliSearch/target/debug/deps/libderive_builder-89e07fb5fce3eab1.rmeta --extern dump=/Users/irevoire/MeiliSearch/target/debug/deps/libdump-fc0e81fab117d9f5.rmeta --extern enum_iterator=/Users/irevoire/MeiliSearch/target/debug/deps/libenum_iterator-31d5bb7725736b45.rmeta --extern file_store=/Users/irevoire/MeiliSearch/target/debug/deps/libfile_store-3c68ffee379da27b.rmeta --extern log=/Users/irevoire/MeiliSearch/target/debug/deps/liblog-c2cab63dc51abb56.rmeta --extern meilisearch_auth=/Users/irevoire/MeiliSearch/target/debug/deps/libmeilisearch_auth-d55d0cbca94e300c.rmeta --extern meilisearch_types=/Users/irevoire/MeiliSearch/target/debug/deps/libmeilisearch_types-1dcdeed227f28f9e.rmeta --extern page_size=/Users/irevoire/MeiliSearch/target/debug/deps/libpage_size-513647d3c9821e59.rmeta --extern parking_lot=/Users/irevoire/MeiliSearch/target/debug/deps/libparking_lot-efe3d286f9f3fed8.rmeta --extern puffin=/Users/irevoire/MeiliSearch/target/debug/deps/libpuffin-0fa06672b498f00d.rmeta --extern roaring=/Users/irevoire/MeiliSearch/target/debug/deps/libroaring-9d813a0d30926f1e.rmeta --extern serde=/Users/irevoire/MeiliSearch/target/debug/deps/libserde-f2942aa2adfdd95b.rmeta --extern serde_json=/Users/irevoire/MeiliSearch/target/debug/deps/libserde_json-071e1d659f08c88a.rmeta --extern strois=/Users/irevoire/MeiliSearch/target/debug/deps/libstrois-8ba618b46df4ac74.rmeta --extern synchronoise=/Users/irevoire/MeiliSearch/target/debug/deps/libsynchronoise-6a3de6ecaf96396f.rmeta --extern tempfile=/Users/irevoire/MeiliSearch/target/debug/deps/libtempfile-86217ddb1d53035b.rmeta --extern thiserror=/Users/irevoire/MeiliSearch/target/debug/deps/libthiserror-acb4966a8a6205e2.rmeta --extern time=/Users/irevoire/MeiliSearch/target/debug/deps/libtime-913d5d01c3c0e43e.rmeta --extern tokio=/Users/irevoire/MeiliSearch/target/debug/deps/libtokio-e0de18e46631c63a.rmeta --extern uuid=/Users/irevoire/MeiliSearch/target/debug/deps/libuuid-f90dd88966a715cc.rmeta --extern zookeeper_client_sync=/Users/irevoire/MeiliSearch/target/debug/deps/libzookeeper_client_sync-dc1316cbe082d16a.rmeta -L native=/Users/irevoire/MeiliSearch/target/debug/build/ring-e7af4fc9a7fe5a3f/out -L native=/Users/irevoire/MeiliSearch/target/debug/build/zstd-sys-efc5b62034a04cff/out -L native=/Users/irevoire/MeiliSearch/target/debug/build/lmdb-rkv-sys-0d91bd9b5f588528/out` (signal: 6, SIGABRT: process abort signal) ```

Here's the attached file: rustc-ice-2023-10-31T16_43_07-34060.txt

matthiaskrgr commented 10 months ago

should be fixed on latest nightly

irevoire commented 10 months ago

Yes it is thanks