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: borrowck best_blame_constraint unwrap on a None value, OpaqueTypeKey { def_id... #133252

Open
Turbo87 opened this issue Nov 20, 2024 · 5 comments
Labels
A-borrow-checker Area: The borrow checker C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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.

Comments

@Turbo87
Copy link
Member

Turbo87 commented Nov 20, 2024

Code

Meta

rustc --version --verbose:

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: aarch64-apple-darwin
release: 1.82.0
LLVM version: 19.1.1

Error output

❯ RUST_BACKTRACE=1 cargo build
   Compiling crates_io v0.0.0 (/Users/tbieniek/Code/crates.io)
thread 'rustc' panicked at compiler/rustc_borrowck/src/region_infer/mod.rs:1967:82:
called `Option::unwrap()` on a `None` value

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: rustc 1.82.0 (f6e511eec 2024-10-15) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED] -C linker=rust-lld

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_borrowck] borrow-checking `controllers::user::me::updates::{closure#0}`
#1 [mir_borrowck] borrow-checking `controllers::user::me::updates`
#2 [type_of_opaque] computing type of opaque `controllers::user::me::updates::{opaque#0}`
#3 [type_of] computing type of `controllers::user::me::updates::{opaque#0}`
#4 [check_well_formed] checking that `controllers::user::me::updates::{opaque#0}` is well-formed
#5 [check_mod_type_wf] checking that types are well-formed in module `controllers::user::me`
#6 [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: {OpaqueTypeKey { def_id: DefId(0:19493 ~ crates_io[d4b9]::controllers::user::me::updates::{opaque#0}), args: [] }: OpaqueTypeDecl { hidden_type: OpaqueHiddenType { span: src/controllers/user/me.rs:68:74: 105:2 (#0), ty: Coroutine(DefId(0:1458 ~ crates_io[d4b9]::controllers::user::me::updates::{closure#0}), [(), std::future::ResumeTy, (), std::result::Result<axum_extra::response::ErasedJson, std::boxed::Box<dyn [Binder { value: Trait(util::errors::AppError), bound_vars: [] }] + '?2, std::alloc::Global>>, CoroutineWitness(DefId(0:1458 ~ crates_io[d4b9]::controllers::user::me::updates::{closure#0}), []), (app::AppState, http::request::Parts)]) } }}
  |
  = note: delayed at compiler/rustc_infer/src/infer/opaque_types/table.rs:44:43
             0: std::backtrace::Backtrace::create
             1: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             2: <rustc_errors::diagnostic::Diag>::emit_producing_error_guaranteed
             3: <rustc_errors::DiagCtxtHandle>::delayed_bug::<alloc::string::String>
             4: core::ptr::drop_in_place::<rustc_infer::infer::opaque_types::table::OpaqueTypeStorage>
             5: core::ptr::drop_in_place::<rustc_borrowck::BorrowckInferCtxt>
             6: rustc_borrowck::do_mir_borrowck
             7: rustc_borrowck::mir_borrowck
             8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
             9: <rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
            10: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            11: rustc_query_impl::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
            12: rustc_hir_analysis::collect::type_of::opaque::find_opaque_ty_constraints_for_rpit
            13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
            14: <rustc_query_impl::query_impl::type_of_opaque::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
            15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            16: rustc_query_impl::query_impl::type_of_opaque::get_query_incr::__rust_end_short_backtrace
            17: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
            18: rustc_hir_analysis::collect::type_of::type_of
            19: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
            20: <rustc_query_impl::query_impl::type_of::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
            21: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            22: rustc_query_impl::query_impl::type_of::get_query_incr::__rust_end_short_backtrace
            23: rustc_hir_analysis::check::check::check_item_type
            24: rustc_hir_analysis::check::wfcheck::check_well_formed
            25: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            26: <rustc_query_impl::query_impl::check_well_formed::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_hir::hir_id::OwnerId)>>::call_once
            27: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_hir::hir_id::OwnerId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            28: rustc_query_impl::query_impl::check_well_formed::get_query_incr::__rust_end_short_backtrace
            29: <rustc_data_structures::sync::parallel::ParallelGuard>::run::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_data_structures::sync::parallel::disabled::try_par_for_each_in<&[rustc_hir::hir::ImplItemId], rustc_span::ErrorGuaranteed, <rustc_middle::hir::ModuleItems>::par_impl_items<rustc_hir_analysis::check::wfcheck::check_mod_type_wf::{closure#1}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
            30: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
            31: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            32: <rustc_query_impl::query_impl::check_mod_type_wf::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalModDefId)>>::call_once
            33: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            34: rustc_query_impl::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace
            35: <rustc_data_structures::sync::parallel::ParallelGuard>::run::<(), rustc_data_structures::sync::parallel::disabled::par_for_each_in<&[rustc_hir::hir_id::OwnerId], <rustc_middle::hir::map::Map>::par_for_each_module<rustc_hir_analysis::check_crate::{closure#0}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
            36: rustc_hir_analysis::check_crate
            37: rustc_interface::passes::analysis
            38: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            39: <rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
            40: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            41: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
            42: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#5}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            43: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
            44: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            45: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            46: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, 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}
            47: std::sys::pal::unix::thread::Thread::new::thread_start
            48: __pthread_joiner_wake
          

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: rustc 1.82.0 (f6e511eec 2024-10-15) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED] -C linker=rust-lld

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
thread 'rustc' panicked at core/src/panicking.rs:229: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: rustc 1.82.0 (f6e511eec 2024-10-15) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED] -C linker=rust-lld

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 `crates_io` (lib)

Caused by:
  process didn't exit successfully: `/Users/tbieniek/.rustup/toolchains/1.82.0-aarch64-apple-darwin/bin/rustc --crate-name crates_io --edition=2021 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=203 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --warn=unused '--warn=rustdoc::unescaped_backticks' '--warn=clippy::todo' --warn=rust_2021_compatibility --warn=rust_2018_idioms --warn=rust_2018_compatibility --warn=nonstandard_style --warn=future_incompatible '--warn=clippy::dbg_macro' --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values())' -C metadata=99351b9735320372 -C extra-filename=-99351b9735320372 --out-dir /Users/tbieniek/Code/crates.io/target/debug/deps -C incremental=/Users/tbieniek/Code/crates.io/target/debug/incremental -L dependency=/Users/tbieniek/Code/crates.io/target/debug/deps --extern anyhow=/Users/tbieniek/Code/crates.io/target/debug/deps/libanyhow-5ca71c7a58ed170f.rmeta --extern async_trait=/Users/tbieniek/Code/crates.io/target/debug/deps/libasync_trait-307a7d505591d425.dylib --extern aws_credential_types=/Users/tbieniek/Code/crates.io/target/debug/deps/libaws_credential_types-81611675731fab26.rmeta --extern aws_ip_ranges=/Users/tbieniek/Code/crates.io/target/debug/deps/libaws_ip_ranges-d9faebcfaf2a57d1.rmeta --extern aws_sdk_cloudfront=/Users/tbieniek/Code/crates.io/target/debug/deps/libaws_sdk_cloudfront-e474f5e76fac66d3.rmeta --extern aws_sdk_sqs=/Users/tbieniek/Code/crates.io/target/debug/deps/libaws_sdk_sqs-822ca5e527aa6078.rmeta --extern axum=/Users/tbieniek/Code/crates.io/target/debug/deps/libaxum-fb262ef8b0d2b21a.rmeta --extern axum_extra=/Users/tbieniek/Code/crates.io/target/debug/deps/libaxum_extra-d1fb8435bf6cb737.rmeta --extern base64=/Users/tbieniek/Code/crates.io/target/debug/deps/libbase64-30d3f1235ae49020.rmeta --extern bigdecimal=/Users/tbieniek/Code/crates.io/target/debug/deps/libbigdecimal-ce42e60acae5ddbf.rmeta --extern bon=/Users/tbieniek/Code/crates.io/target/debug/deps/libbon-c4615a0b2a0e4afe.rmeta --extern cargo_manifest=/Users/tbieniek/Code/crates.io/target/debug/deps/libcargo_manifest-fc5ea574fe898a08.rmeta --extern chrono=/Users/tbieniek/Code/crates.io/target/debug/deps/libchrono-e0f4d3b1f057640e.rmeta --extern clap=/Users/tbieniek/Code/crates.io/target/debug/deps/libclap-d693acc1a86562c5.rmeta --extern colored=/Users/tbieniek/Code/crates.io/target/debug/deps/libcolored-d2305004cb1cbea7.rmeta --extern cookie=/Users/tbieniek/Code/crates.io/target/debug/deps/libcookie-3075eb2a4765c070.rmeta --extern crates_io_cdn_logs=/Users/tbieniek/Code/crates.io/target/debug/deps/libcrates_io_cdn_logs-430de7d1a6b9145e.rmeta --extern crates_io_database=/Users/tbieniek/Code/crates.io/target/debug/deps/libcrates_io_database-8c1406b9ca7a2d9b.rmeta --extern crates_io_database_dump=/Users/tbieniek/Code/crates.io/target/debug/deps/libcrates_io_database_dump-b29343cf5a1de18a.rmeta --extern crates_io_env_vars=/Users/tbieniek/Code/crates.io/target/debug/deps/libcrates_io_env_vars-cf8a82b6c3545853.rmeta --extern crates_io_github=/Users/tbieniek/Code/crates.io/target/debug/deps/libcrates_io_github-c019efb5ad5a4d45.rmeta --extern crates_io_index=/Users/tbieniek/Code/crates.io/target/debug/deps/libcrates_io_index-8adf1152f54775da.rmeta --extern crates_io_markdown=/Users/tbieniek/Code/crates.io/target/debug/deps/libcrates_io_markdown-870ef60d34b29ff2.rmeta --extern crates_io_pagerduty=/Users/tbieniek/Code/crates.io/target/debug/deps/libcrates_io_pagerduty-42fcc5f007778fa2.rmeta --extern crates_io_tarball=/Users/tbieniek/Code/crates.io/target/debug/deps/libcrates_io_tarball-f2a535c2cad06ee8.rmeta --extern crates_io_team_repo=/Users/tbieniek/Code/crates.io/target/debug/deps/libcrates_io_team_repo-61fff7575af38f3f.rmeta --extern crates_io_worker=/Users/tbieniek/Code/crates.io/target/debug/deps/libcrates_io_worker-23ba914000f90b5d.rmeta --extern csv=/Users/tbieniek/Code/crates.io/target/debug/deps/libcsv-219aece62ec726b2.rmeta --extern deadpool_diesel=/Users/tbieniek/Code/crates.io/target/debug/deps/libdeadpool_diesel-e0bf930853aa99da.rmeta --extern derive_deref=/Users/tbieniek/Code/crates.io/target/debug/deps/libderive_deref-a287df1790ba5c6d.dylib --extern dialoguer=/Users/tbieniek/Code/crates.io/target/debug/deps/libdialoguer-1104d613c529dc8c.rmeta --extern diesel=/Users/tbieniek/Code/crates.io/target/debug/deps/libdiesel-c4ace3f1ab1d59fb.rmeta --extern diesel_async=/Users/tbieniek/Code/crates.io/target/debug/deps/libdiesel_async-fb768a0d73fb3d45.rmeta --extern diesel_full_text_search=/Users/tbieniek/Code/crates.io/target/debug/deps/libdiesel_full_text_search-a66d600d17830e2a.rmeta --extern diesel_migrations=/Users/tbieniek/Code/crates.io/target/debug/deps/libdiesel_migrations-7bc75d31859a993e.rmeta --extern dotenvy=/Users/tbieniek/Code/crates.io/target/debug/deps/libdotenvy-44dac4d976c9f45d.rmeta --extern flate2=/Users/tbieniek/Code/crates.io/target/debug/deps/libflate2-437a1b6af3f22b45.rmeta --extern futures_util=/Users/tbieniek/Code/crates.io/target/debug/deps/libfutures_util-9a4ad87fb22e8e3e.rmeta --extern hex=/Users/tbieniek/Code/crates.io/target/debug/deps/libhex-3dc383cbf9b09120.rmeta --extern http=/Users/tbieniek/Code/crates.io/target/debug/deps/libhttp-da6e0dc45fb6c606.rmeta --extern http_body_util=/Users/tbieniek/Code/crates.io/target/debug/deps/libhttp_body_util-56ed164f2d59b268.rmeta --extern hyper=/Users/tbieniek/Code/crates.io/target/debug/deps/libhyper-be058bfa354519ca.rmeta --extern indexmap=/Users/tbieniek/Code/crates.io/target/debug/deps/libindexmap-db507b5cc98e5bcf.rmeta --extern indicatif=/Users/tbieniek/Code/crates.io/target/debug/deps/libindicatif-b55e063ede31cf28.rmeta --extern ipnetwork=/Users/tbieniek/Code/crates.io/target/debug/deps/libipnetwork-5a3aa856f5f1c6bb.rmeta --extern json_subscriber=/Users/tbieniek/Code/crates.io/target/debug/deps/libjson_subscriber-47b30049cc5ff60c.rmeta --extern lettre=/Users/tbieniek/Code/crates.io/target/debug/deps/liblettre-fead64a1b8477dd4.rmeta --extern minijinja=/Users/tbieniek/Code/crates.io/target/debug/deps/libminijinja-016e3a23f2e6aba9.rmeta --extern mockall=/Users/tbieniek/Code/crates.io/target/debug/deps/libmockall-a06eb72a0effd3c8.rmeta --extern native_tls=/Users/tbieniek/Code/crates.io/target/debug/deps/libnative_tls-4cec392b2d76b5b6.rmeta --extern oauth2=/Users/tbieniek/Code/crates.io/target/debug/deps/liboauth2-4f9ec6f85fdf646e.rmeta --extern object_store=/Users/tbieniek/Code/crates.io/target/debug/deps/libobject_store-3a2b97f0b728e1eb.rmeta --extern p256=/Users/tbieniek/Code/crates.io/target/debug/deps/libp256-7b2c5669ba82c672.rmeta --extern parking_lot=/Users/tbieniek/Code/crates.io/target/debug/deps/libparking_lot-3fc0ca7f2ad2ab20.rmeta --extern paste=/Users/tbieniek/Code/crates.io/target/debug/deps/libpaste-16af04d90bc67ea6.dylib --extern postgres_native_tls=/Users/tbieniek/Code/crates.io/target/debug/deps/libpostgres_native_tls-1b0ce9b19e455140.rmeta --extern prometheus=/Users/tbieniek/Code/crates.io/target/debug/deps/libprometheus-d28700cd5f48bd0c.rmeta --extern rand=/Users/tbieniek/Code/crates.io/target/debug/deps/librand-3ae4a8fa71126bf0.rmeta --extern reqwest=/Users/tbieniek/Code/crates.io/target/debug/deps/libreqwest-de4e25c98f4ec447.rmeta --extern rss=/Users/tbieniek/Code/crates.io/target/debug/deps/librss-69e970b8b082b7e2.rmeta --extern secrecy=/Users/tbieniek/Code/crates.io/target/debug/deps/libsecrecy-2e5f3b76f1c5dc15.rmeta --extern semver=/Users/tbieniek/Code/crates.io/target/debug/deps/libsemver-8a3039fd3dcd7fcd.rmeta --extern sentry=/Users/tbieniek/Code/crates.io/target/debug/deps/libsentry-99382909ea24cab8.rmeta --extern serde=/Users/tbieniek/Code/crates.io/target/debug/deps/libserde-84c3f579b916f935.rmeta --extern serde_json=/Users/tbieniek/Code/crates.io/target/debug/deps/libserde_json-aa2e259ff63820a5.rmeta --extern sha2=/Users/tbieniek/Code/crates.io/target/debug/deps/libsha2-62b66cfe559c81f1.rmeta --extern spdx=/Users/tbieniek/Code/crates.io/target/debug/deps/libspdx-781d95e4f990d03d.rmeta --extern tar=/Users/tbieniek/Code/crates.io/target/debug/deps/libtar-3442c1d658cdc4f0.rmeta --extern tempfile=/Users/tbieniek/Code/crates.io/target/debug/deps/libtempfile-e7da20a1f1067c86.rmeta --extern thiserror=/Users/tbieniek/Code/crates.io/target/debug/deps/libthiserror-78e82ff47f28fbd9.rmeta --extern tikv_jemallocator=/Users/tbieniek/Code/crates.io/target/debug/deps/libtikv_jemallocator-0d9a7f9692e1ebcf.rmeta --extern tokio=/Users/tbieniek/Code/crates.io/target/debug/deps/libtokio-8d4b40d39bfb0f32.rmeta --extern tokio_postgres=/Users/tbieniek/Code/crates.io/target/debug/deps/libtokio_postgres-f791ee1d2b94c5ab.rmeta --extern toml=/Users/tbieniek/Code/crates.io/target/debug/deps/libtoml-34bd9491a830b9bc.rmeta --extern tower=/Users/tbieniek/Code/crates.io/target/debug/deps/libtower-1e8762fe8201319a.rmeta --extern tower_http=/Users/tbieniek/Code/crates.io/target/debug/deps/libtower_http-9fae09c34c328d92.rmeta --extern tracing=/Users/tbieniek/Code/crates.io/target/debug/deps/libtracing-3060f4f7ebe0a86a.rmeta --extern tracing_subscriber=/Users/tbieniek/Code/crates.io/target/debug/deps/libtracing_subscriber-72afc66271472a0c.rmeta --extern typomania=/Users/tbieniek/Code/crates.io/target/debug/deps/libtypomania-b75a54b8c8632507.rmeta --extern unicode_xid=/Users/tbieniek/Code/crates.io/target/debug/deps/libunicode_xid-6cb93bfb418c350f.rmeta --extern url=/Users/tbieniek/Code/crates.io/target/debug/deps/liburl-650d0b0c5171d7dd.rmeta -C linker=rust-lld -L native=/Users/tbieniek/Code/crates.io/target/debug/build/ring-ced8403dbfcec192/out -L native=/Users/tbieniek/Code/crates.io/target/debug/build/zstd-sys-2d97206ebe9d75d0/out -L native=/opt/homebrew/opt/libpq/lib -L native=/Users/tbieniek/Code/crates.io/target/debug/build/libgit2-sys-55aaf7d7adc49576/out/build -L native=/Users/tbieniek/Code/crates.io/target/debug/build/libssh2-sys-bcbb7f91d703f504/out/build -L 'native=/opt/homebrew/opt/openssl@3/lib' -L native=/Users/tbieniek/Code/crates.io/target/debug/build/psm-a24ca136e31f5ebc/out -L native=/Users/tbieniek/Code/crates.io/target/debug/build/tikv-jemalloc-sys-6a0077a245cdaa58/out/build/lib` (signal: 6, SIGABRT: process abort signal)
Backtrace

stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: <rustc_borrowck::region_infer::RegionInferenceContext>::best_blame_constraint::<<rustc_borrowck::MirBorrowckCtxt>::free_region_constraint_info::{closure#0}>
   5: <rustc_borrowck::MirBorrowckCtxt>::explain_why_borrow_contains_point
   6: <rustc_borrowck::MirBorrowckCtxt>::report_borrowed_value_does_not_live_long_enough
   7: rustc_borrowck::path_utils::each_borrow_involving_path::<<rustc_borrowck::MirBorrowckCtxt>::check_access_for_conflict::{closure#1}, <rustc_borrowck::MirBorrowckCtxt>::check_access_for_conflict::{closure#0}, rustc_borrowck::MirBorrowckCtxt>
   8: <rustc_borrowck::MirBorrowckCtxt>::access_place
   9: <rustc_borrowck::MirBorrowckCtxt as rustc_mir_dataflow::framework::visitor::ResultsVisitor<rustc_borrowck::dataflow::BorrowckResults>>::visit_terminator_before_primary_effect
  10: <rustc_mir_dataflow::framework::direction::Forward as rustc_mir_dataflow::framework::direction::Direction>::visit_results_in_block::<rustc_borrowck::dataflow::BorrowckFlowState, rustc_borrowck::dataflow::BorrowckResults, rustc_borrowck::MirBorrowckCtxt>
  11: rustc_mir_dataflow::framework::visitor::visit_results::<rustc_borrowck::dataflow::BorrowckFlowState, rustc_borrowck::dataflow::BorrowckResults, core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::mir::BasicBlock>, rustc_middle::mir::traversal::reverse_postorder::{closure#0}>, rustc_borrowck::do_mir_borrowck::{closure#2}>, rustc_borrowck::MirBorrowckCtxt>
  12: rustc_borrowck::do_mir_borrowck
  13: rustc_borrowck::mir_borrowck
      [... omitted 2 frames ...]
  14: <rustc_borrowck::type_check::TypeChecker>::prove_closure_bounds
  15: <rustc_borrowck::type_check::TypeChecker>::check_rvalue
  16: <rustc_borrowck::type_check::TypeChecker>::typeck_mir
  17: rustc_borrowck::type_check::type_check
  18: rustc_borrowck::nll::compute_regions
  19: rustc_borrowck::do_mir_borrowck
  20: rustc_borrowck::mir_borrowck
      [... omitted 2 frames ...]
  21: rustc_hir_analysis::collect::type_of::opaque::find_opaque_ty_constraints_for_rpit
      [... omitted 2 frames ...]
  22: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
  23: rustc_hir_analysis::collect::type_of::type_of
      [... omitted 2 frames ...]
  24: rustc_hir_analysis::check::check::check_item_type
  25: rustc_hir_analysis::check::wfcheck::check_well_formed
      [... omitted 2 frames ...]
  26: <rustc_data_structures::sync::parallel::ParallelGuard>::run::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_data_structures::sync::parallel::disabled::try_par_for_each_in<&[rustc_hir::hir::ImplItemId], rustc_span::ErrorGuaranteed, <rustc_middle::hir::ModuleItems>::par_impl_items<rustc_hir_analysis::check::wfcheck::check_mod_type_wf::{closure#1}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
  27: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
      [... omitted 2 frames ...]
  28: <rustc_data_structures::sync::parallel::ParallelGuard>::run::<(), rustc_data_structures::sync::parallel::disabled::par_for_each_in<&[rustc_hir::hir_id::OwnerId], <rustc_middle::hir::map::Map>::par_for_each_module<rustc_hir_analysis::check_crate::{closure#0}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
  29: rustc_hir_analysis::check_crate
  30: rustc_interface::passes::analysis
      [... omitted 2 frames ...]
  31: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#5}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  32: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
  33: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>

@Turbo87 Turbo87 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 Nov 20, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 20, 2024
@Turbo87
Copy link
Member Author

Turbo87 commented Nov 20, 2024

/cc @estebank since this seems to be diagnostics-related (?)

@jieyouxu
Copy link
Member

jieyouxu commented Nov 20, 2024

Backtrace looks like #114640. ICE'd while borrow-checking around https://github.com/Turbo87/crates.io/blob/cf1ac7c853bc4cea21a8fd3fdb7e17260d1a242c/src/controllers/user/me.rs#L68.

#[instrument(level = "debug", skip(self, target_test))]
pub(crate) fn best_blame_constraint(
&self,
from_region: RegionVid,
from_region_origin: NllRegionVariableOrigin,
target_test: impl Fn(RegionVid) -> bool,
) -> (BlameConstraint<'tcx>, Vec<ExtraConstraintInfo>) {
// Find all paths
let (path, target_region) =
self.find_constraint_paths_between_regions(from_region, target_test).unwrap();

It looks a bit like #114640 and #123157, but #123157 is feature-gated-dependent.

@Turbo87 does it repro if you cargo clean then check/build again?

@jieyouxu jieyouxu added the A-borrow-checker Area: The borrow checker label Nov 20, 2024
@jieyouxu jieyouxu changed the title rustc_errors::DiagCtxtInner::emit_diagnostic: called Option::unwrap() on a None value ICE: borrowck best_blame_constraint unwrap on a None value, OpaqueTypeKey { def_id... Nov 20, 2024
@Turbo87
Copy link
Member Author

Turbo87 commented Nov 20, 2024

does it repro if you cargo clean then check/build again?

yep, reproduces every time I run, also when running cargo clean or rm -rf target before the cargo build. also happens on cargo check and cargo clippy.

@jieyouxu
Copy link
Member

Thanks for the info. That is certainly curious.
@rustbot label +E-needs-mcve

@rustbot rustbot added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Nov 20, 2024
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 20, 2024
@cyrgani
Copy link
Contributor

cyrgani commented Nov 20, 2024

Partial reduction:

use diesel::associations::{BelongsTo, HasTable};
use diesel::deserialize::{self, FromStaticSqlRow};
use diesel::pg::Pg;
use diesel::query_builder::{AsQuery, AstPass, Query, QueryFragment};
use diesel::query_dsl::CompatibleType;
use diesel::{
    BelongingToDsl, ExpressionMethods, Identifiable, QueryDsl, QueryResult, Queryable, Selectable,
    SelectableHelper,
};
use std::future::Future;

impl<T: Send> ResolveThis for T {}
trait ResolveThis {
    fn resolve(&self) {}
}

diesel::table! {
    crates (id) {
        id -> Int4,
    }
}

diesel::table! {
    follows (user_id, crate_id) {
        user_id -> Int4,
        crate_id -> Int4,
    }
}

diesel::table! {
    users (id) {
        id -> Int4,
    }
}

diesel::table! {
    versions (id) {
        id -> Int4,
        crate_id -> Int4,
        published_by -> Nullable<Int4>,
    }
}

diesel::joinable!(versions -> crates (crate_id));
diesel::joinable!(versions -> users (published_by));

diesel::allow_tables_to_appear_in_same_query!(crates, follows, users, versions,);

struct PaginatedQuery<T>(T);
impl<T> PaginatedQuery<T> {
    async fn async_load<'a, U>(&self)
    where
        Self: LoadQuery<'a, WithCount<U>>,
    {
        self.internal_load().await;
    }
}
impl<T: Query> Query for PaginatedQuery<T> {
    type SqlType = (T::SqlType,);
}
impl<T> QueryFragment<Pg> for PaginatedQuery<T> {
    fn walk_ast<'b>(&'b self, _out: AstPass<'_, 'b, Pg>) -> QueryResult<()> {
        loop {}
    }
}
trait AppError: 'static {}

fn ice() -> impl Future<Output = Option<Box<dyn AppError>>> {
    async {
        let user = User { id: 0 };
        let followed_crates = Follow::belonging_to(&user).select(follows::crate_id);
        let query = PaginatedQuery(
            versions::table
                .inner_join(crates::table)
                .left_outer_join(users::table)
                .filter(crates::id.eq_any(followed_crates))
                .select(<Option<User>>::as_select()),
        );
        query.async_load().resolve();
        None
    }
}
struct WithCount<T> {
    record: T,
}
impl<T, __ST0> Queryable<__ST0, Pg> for WithCount<T>
where
    (T,): FromStaticSqlRow<__ST0, Pg>,
{
    type Row = (T,);
    fn build(row: Self::Row) -> deserialize::Result<Self> {
        loop {}
    }
}
struct Follow {
    user_id: i32,
}
impl HasTable for Follow {
    type Table = follows::table;
    fn table() -> Self::Table {
        loop {}
    }
}

impl<__FK> BelongsTo<User> for Follow
where
    __FK: std::hash::Hash + std::cmp::Eq,
    for<'__a> &'__a User: Identifiable<Id = &'__a __FK>,
{
    type ForeignKey = __FK;
    type ForeignKeyColumn = follows::user_id;
    fn foreign_key(&self) -> Option<&Self::ForeignKey> {
        loop {}
    }
    fn foreign_key_column() -> Self::ForeignKeyColumn {
        loop {}
    }
}
struct User {
    id: i32,
}
impl<__ST0> Queryable<__ST0, Pg> for User
where
    (i32,): FromStaticSqlRow<__ST0, Pg>,
{
    type Row = (i32,);
    fn build(row: Self::Row) -> deserialize::Result<Self> {
        loop {}
    }
}
impl HasTable for User {
    type Table = users::table;
    fn table() -> Self::Table {
        users::table
    }
}
impl<'ident> Identifiable for &'ident User {
    type Id = &'ident i32;
    fn id(self) -> Self::Id {
        loop {}
    }
}
impl Selectable<Pg> for User {
    type SelectExpression = (users::id,);
    fn construct_selection() -> Self::SelectExpression {
        loop {}
    }
}

trait LoadQuery<'query, U> {
    type LoadFuture: Future;

    fn internal_load(&self) -> Self::LoadFuture {
        loop {}
    }
}

impl<'query, T, U> LoadQuery<'query, U> for T
where
    T: AsQuery + 'query,
    T::SqlType: CompatibleType<U, Pg>,
{
    type LoadFuture = MapOk;
}

struct MapOk;
impl Future for MapOk {
    type Output = ();
    fn poll(
        self: std::pin::Pin<&mut Self>,
        _: &mut std::task::Context<'_>,
    ) -> std::task::Poll<Self::Output> {
        todo!()
    }
}
[dependencies]
diesel = { version = "=2.2.4", features = ["postgres", "i-implement-a-third-party-backend-and-opt-into-breaking-changes"] }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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.
Projects
None yet
Development

No branches or pull requests

4 participants