Repository: rust
Issue: Compiler panic: evaluating trait selection obligation
Labels: I-ICE,T-compiler,C-bug,S-needs-repro

### Code

I don't have a minimal reproducer at hand unfortunately, and cannot share our proprietary code base with you. Sorry.
The project uses `sqlx` with a postgres database that has just freshly been migrated, if that is of any relevance.

I cannot reproduce the bug after `cargo clean`, so this is possibly a poisoned / corrupted cache. (Still reporting this since `rustc` has asked me to)

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.65.0 (897e37553 2022-11-02)
```

### Error output

```
warning: build failed, waiting for other jobs to finish...
thread 'rustc' panicked at 'Failed to extract DefId: local_def_id_to_hir_id c869a85bf893cd50-df66789a2c5c4d83', compiler/rustc_middle/src/dep_graph/dep_node.rs:267:17
<SNIP: stacktrace below>
error: internal compiler error: unexpected panic

note: 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.65.0 (897e37553 2022-11-02) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C incremental=[REDACTED] -C link-arg=-fuse-ld=lld -C force-frame-pointers=yes -C link-arg=-Wl,--compress-debug-sections=zlib,--no-rosegment

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `some_lib::Control<fnord::fnord_impl::transitions::States>: core::marker::Send`
#1 [codegen_select_candidate] computing candidate for `<core::pin::Pin<alloc::boxed::Box<core::future::from_generator::GenFuture<[static generator@libs/stuff/src/service.rs:28:83: 62:6]>>> as core::ops::unsize::CoerceUnsized<core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = core::result::Result<tonic::response::Response<proto::stuff_v1::StuffResponse>, tonic::status::Status>> + core::marker::Send>>>>`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
#3 [exported_symbols] exported_symbols
end of query stack

```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>

```
stack backtrace:
   0:     0x7feef316dd40 - std::backtrace_rs::backtrace::libunwind::trace::h32eb3e08e874dd27
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7feef316dd40 - std::backtrace_rs::backtrace::trace_unsynchronized::haa3f451d27bc11a5
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7feef316dd40 - std::sys_common::backtrace::_print_fmt::h5b94a01bb4289bb5
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7feef316dd40 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb070b7fa7e3175df
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7feef31c8bfe - core::fmt::write::hd5207aebbb9a86e9
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/fmt/mod.rs:1202:17
   5:     0x7feef315e935 - std::io::Write::write_fmt::h3bd699bbd129ab8a
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/io/mod.rs:1679:15
   6:     0x7feef31709f3 - std::sys_common::backtrace::_print::h7a21be552fdf58da
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7feef31709f3 - std::sys_common::backtrace::print::ha85c41fe4dd80b13
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7feef31709f3 - std::panicking::default_hook::{{closure}}::h04cca40023d0eeca
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:295:22
   9:     0x7feef31706df - std::panicking::default_hook::haa3ca8c310ed5402
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:314:9
  10:     0x7feef599e2e1 - rustc_driver[cfb34b1539811fe8]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7feef317122d - std::panicking::rust_panic_with_hook::h7b190ce1a948faac
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:702:17
  12:     0x7feef3171087 - std::panicking::begin_panic_handler::{{closure}}::hbafbfdc3e1b97f68
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:588:13
  13:     0x7feef316e1ec - std::sys_common::backtrace::__rust_end_short_backtrace::hda93e5fef243b4c0
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7feef3170da2 - rust_begin_unwind
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:584:5
  15:     0x7feef31c57d3 - core::panicking::panic_fmt::h8d17ca1073d9a733
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:142:14
  16:     0x7feef69bbf61 - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::dep_node::DepNode<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind> as rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepNodeExt>::extract_def_id::{closure#0}
  17:     0x7feef42d2e3b - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::dep_node::DepNode<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind> as rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepNodeExt>::extract_def_id
  18:     0x7feef52ba6bc - rustc_query_impl[d6191eea714bd250]::plumbing::force_from_dep_node::<rustc_query_impl[d6191eea714bd250]::queries::local_def_id_to_hir_id>
  19:     0x7feef4424291 - <rustc_middle[a9ca1c3f9fd197cd]::ty::context::TyCtxt as rustc_query_system[860ed7b39cdfb46b]::dep_graph::DepContext>::try_force_from_dep_node
  20:     0x7feef4423022 - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt>
  21:     0x7feef4422ff0 - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt>
  22:     0x7feef4422ff0 - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt>
  23:     0x7feef4422ff0 - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt>
  24:     0x7feef4e780ca - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::get_query::<rustc_query_impl[d6191eea714bd250]::queries::evaluate_obligation, rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt>
  25:     0x7feef4e77235 - <rustc_query_impl[d6191eea714bd250]::Queries as rustc_middle[a9ca1c3f9fd197cd]::ty::query::QueryEngine>::evaluate_obligation
  26:     0x7feef4636937 - <rustc_trait_selection[f6cb7b5468c1337d]::traits::fulfill::FulfillProcessor as rustc_data_structures[62ce3989ce8140ee]::obligation_forest::ObligationProcessor>::process_obligation
  27:     0x7feef4633d0f - <rustc_data_structures[62ce3989ce8140ee]::obligation_forest::ObligationForest<rustc_trait_selection[f6cb7b5468c1337d]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[f6cb7b5468c1337d]::traits::fulfill::FulfillProcessor, rustc_data_structures[62ce3989ce8140ee]::obligation_forest::Outcome<rustc_trait_selection[f6cb7b5468c1337d]::traits::fulfill::PendingPredicateObligation, rustc_infer[ed26b14e1208c12f]::traits::FulfillmentErrorCode>>
  28:     0x7feef518a41b - <rustc_trait_selection[f6cb7b5468c1337d]::traits::fulfill::FulfillmentContext as rustc_infer[ed26b14e1208c12f]::traits::engine::TraitEngine>::select_all_or_error
  29:     0x7feef5188ee4 - <rustc_infer[ed26b14e1208c12f]::infer::InferCtxtBuilder>::enter::<core[8c92e53db3fc2eaa]::result::Result<&rustc_middle[a9ca1c3f9fd197cd]::traits::ImplSource<()>, rustc_middle[a9ca1c3f9fd197cd]::traits::CodegenObligationError>, rustc_trait_selection[f6cb7b5468c1337d]::traits::codegen::codegen_select_candidate::{closure#0}>
  30:     0x7feef5188727 - rustc_trait_selection[f6cb7b5468c1337d]::traits::codegen::codegen_select_candidate
  31:     0x7feef516cb72 - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[a9ca1c3f9fd197cd]::ty::context::TyCtxt, (rustc_middle[a9ca1c3f9fd197cd]::ty::ParamEnv, rustc_middle[a9ca1c3f9fd197cd]::ty::sty::Binder<rustc_middle[a9ca1c3f9fd197cd]::ty::sty::TraitRef>), core[8c92e53db3fc2eaa]::result::Result<&rustc_middle[a9ca1c3f9fd197cd]::traits::ImplSource<()>, rustc_middle[a9ca1c3f9fd197cd]::traits::CodegenObligationError>>
  32:     0x7feef516ac1d - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::try_execute_query::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt, rustc_query_system[860ed7b39cdfb46b]::query::caches::DefaultCache<(rustc_middle[a9ca1c3f9fd197cd]::ty::ParamEnv, rustc_middle[a9ca1c3f9fd197cd]::ty::sty::Binder<rustc_middle[a9ca1c3f9fd197cd]::ty::sty::TraitRef>), core[8c92e53db3fc2eaa]::result::Result<&rustc_middle[a9ca1c3f9fd197cd]::traits::ImplSource<()>, rustc_middle[a9ca1c3f9fd197cd]::traits::CodegenObligationError>>>
  33:     0x7feef58dce70 - <rustc_query_impl[d6191eea714bd250]::Queries as rustc_middle[a9ca1c3f9fd197cd]::ty::query::QueryEngine>::codegen_select_candidate
  34:     0x7feef452572d - rustc_monomorphize[cf985dc40f3244e0]::custom_coerce_unsize_info
  35:     0x7feef4520f79 - rustc_monomorphize[cf985dc40f3244e0]::collector::find_vtable_types_for_unsizing
  36:     0x7feef4515ad3 - rustc_monomorphize[cf985dc40f3244e0]::collector::collect_neighbours
  37:     0x7feef45112d2 - rustc_monomorphize[cf985dc40f3244e0]::collector::collect_items_rec
  38:     0x7feef514e4a0 - <rustc_session[c5946fac61f8bc34]::session::Session>::time::<(), rustc_monomorphize[cf985dc40f3244e0]::collector::collect_crate_mono_items::{closure#1}>
  39:     0x7feef514e039 - rustc_monomorphize[cf985dc40f3244e0]::collector::collect_crate_mono_items
  40:     0x7feef514cf26 - rustc_monomorphize[cf985dc40f3244e0]::partitioning::collect_and_partition_mono_items
  41:     0x7feef5749966 - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[a9ca1c3f9fd197cd]::ty::context::TyCtxt, (), (&std[71cb4861428b0c25]::collections::hash::set::HashSet<rustc_span[8f00505efff112e2]::def_id::DefId, core[8c92e53db3fc2eaa]::hash::BuildHasherDefault<rustc_hash[dd1cba6d0ac404d]::FxHasher>>, &[rustc_middle[a9ca1c3f9fd197cd]::mir::mono::CodegenUnit])>
  42:     0x7feef5748ae8 - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::try_execute_query::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt, rustc_query_system[860ed7b39cdfb46b]::query::caches::DefaultCache<(), (&std[71cb4861428b0c25]::collections::hash::set::HashSet<rustc_span[8f00505efff112e2]::def_id::DefId, core[8c92e53db3fc2eaa]::hash::BuildHasherDefault<rustc_hash[dd1cba6d0ac404d]::FxHasher>>, &[rustc_middle[a9ca1c3f9fd197cd]::mir::mono::CodegenUnit])>>
  43:     0x7feef57484ab - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::get_query::<rustc_query_impl[d6191eea714bd250]::queries::collect_and_partition_mono_items, rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt>
  44:     0x7feef57483ee - <rustc_query_impl[d6191eea714bd250]::Queries as rustc_middle[a9ca1c3f9fd197cd]::ty::query::QueryEngine>::collect_and_partition_mono_items
  45:     0x7feef579eb66 - rustc_codegen_ssa[7e4ef4cea483afdf]::back::symbol_export::exported_symbols_provider_local
  46:     0x7feef563010a - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[a9ca1c3f9fd197cd]::ty::context::TyCtxt, rustc_span[8f00505efff112e2]::def_id::CrateNum, &[(rustc_middle[a9ca1c3f9fd197cd]::middle::exported_symbols::ExportedSymbol, rustc_middle[a9ca1c3f9fd197cd]::middle::exported_symbols::SymbolExportInfo)]>
  47:     0x7feef562ec6e - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::try_execute_query::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt, rustc_query_system[860ed7b39cdfb46b]::query::caches::DefaultCache<rustc_span[8f00505efff112e2]::def_id::CrateNum, &[(rustc_middle[a9ca1c3f9fd197cd]::middle::exported_symbols::ExportedSymbol, rustc_middle[a9ca1c3f9fd197cd]::middle::exported_symbols::SymbolExportInfo)]>>
  48:     0x7feef562e3c9 - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::get_query::<rustc_query_impl[d6191eea714bd250]::queries::exported_symbols, rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt>
  49:     0x7feef4d2c2aa - <rustc_metadata[d8be3da67d4a4339]::rmeta::encoder::EncodeContext>::encode_crate_root
  50:     0x7feef48bac42 - rustc_metadata[d8be3da67d4a4339]::rmeta::encoder::encode_metadata_impl
  51:     0x7feef489d64e - rustc_data_structures[62ce3989ce8140ee]::sync::join::<rustc_metadata[d8be3da67d4a4339]::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata[d8be3da67d4a4339]::rmeta::encoder::encode_metadata::{closure#1}, (), ()>
  52:     0x7feef489d539 - rustc_metadata[d8be3da67d4a4339]::rmeta::encoder::encode_metadata
  53:     0x7feef489c623 - rustc_metadata[d8be3da67d4a4339]::fs::encode_and_write_metadata
  54:     0x7feef4890342 - <rustc_interface[3182dd864eff9d7d]::passes::QueryContext>::enter::<<rustc_interface[3182dd864eff9d7d]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<alloc[188ed69dc0d14b4b]::boxed::Box<dyn core[8c92e53db3fc2eaa]::any::Any>, rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  55:     0x7feef484fe73 - <rustc_interface[3182dd864eff9d7d]::queries::Queries>::ongoing_codegen
  56:     0x7feef484e2ca - rustc_interface[3182dd864eff9d7d]::interface::create_compiler_and_run::<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>
  57:     0x7feef484cac1 - <scoped_tls[e395fa6e23b19669]::ScopedKey<rustc_span[8f00505efff112e2]::SessionGlobals>>::set::<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  58:     0x7feef484c7af - std[71cb4861428b0c25]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3182dd864eff9d7d]::util::run_in_thread_pool_with_globals<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  59:     0x7feef5801d70 - <<std[71cb4861428b0c25]::thread::Builder>::spawn_unchecked_<rustc_interface[3182dd864eff9d7d]::util::run_in_thread_pool_with_globals<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#1} as core[8c92e53db3fc2eaa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  60:     0x7feef317b003 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h49f797984e2121bf
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/alloc/src/boxed.rs:1940:9
  61:     0x7feef317b003 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfa4f3d0ee6440e0b
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/alloc/src/boxed.rs:1940:9
  62:     0x7feef317b003 - std::sys::unix::thread::Thread::new::thread_start::h62ca48b42d48a8fc
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys/unix/thread.rs:108:17
  63:     0x7feef2f1c8fd - <unknown>
  64:     0x7feef2f9ea60 - <unknown>
  65:                0x0 - <unknown>

```

</p>
</details>