Repository: rust
Issue: ICE when resolving auto traits during incremental compilation
Labels: I-ICE,T-compiler,A-incr-comp,C-bug,E-needs-mcve

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.

http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/

-->

Possibly related:
https://github.com/rust-lang/rust/issues/102739


### Code

Unfortunately, this is probably an incremental compilation issue, so probably not reproducible. This is the 3rd time I've run into this in the last day. `cargo clean -p <my-crate>` seems to fix it. The previous issues were also with `Send` and `Sync` so it appears to be an issue with resolving auto traits. The `UserComparison` struct is auto generated by a proc-macro that had changes made to it.

### 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-beta.1 (2a65764f2 2022-09-19)
binary: rustc
commit-hash: 2a65764f21cf10b7e03c645f1ad0946e42758e0a
commit-date: 2022-09-19
host: aarch64-apple-darwin
release: 1.65.0-beta.1
LLVM version: 15.0.0
```

### Error output

This is everything except the stack trace

```
error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: rustc 1.65.0-beta.1 (2a65764f2 2022-09-19) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -C opt-level=3 -C lto=off -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C debug-assertions=on -C linker=clang -C incremental=[REDACTED] -C link-arg=-fuse-ld=mold -C target-cpu=native

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `subgraph::UserComparison: core::marker::Sync`  |  = note: this failure-note originates in the attribute macro `entity` (in Nightly builds, run with -Z macro-backtrace for more info)

#1 [check_well_formed] checking that `subgraph::<impl at src/subgraph.rs:272:1: 277:3>` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in module `subgraph`
#3 [analysis] running analysis passes on this crate
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>

```
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_metadata/src/rmeta/def_path_hash_map.rs:23:62
stack backtrace:
   0:        0x101563774 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc14c2fbe7eab7edd
   1:        0x1015adca4 - core::fmt::write::hf7ba2d9322b02f7b
   2:        0x101556714 - std::io::Write::write_fmt::hcbbe9804d68b1866
   3:        0x101565ff0 - std::panicking::default_hook::{{closure}}::h074c918006a712d7
   4:        0x101565d14 - std::panicking::default_hook::hcb4fc0515f47d0e1
   5:        0x1092d5c74 - rustc_driver[51b00cac61f89616]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:        0x1015666b4 - std::panicking::rust_panic_with_hook::hda85dfcaf11e28f6
   7:        0x101566524 - std::panicking::begin_panic_handler::{{closure}}::hacac2c8511d70f3d
   8:        0x101563bdc - std::sys_common::backtrace::__rust_end_short_backtrace::h1f4cf35d9dc62d33
   9:        0x1015662b4 - _rust_begin_unwind
  10:        0x1015d7714 - core::panicking::panic_fmt::h7cea19b1cbddf8d1
  11:        0x1015d7634 - core::panicking::panic::h231bcc5267006a51
  12:        0x10c87adb8 - <rustc_metadata[cc5ee6ef5fe136c4]::creader::CStore as rustc_session[11f94df6f0b47447]::cstore::CrateStore>::def_path_hash_to_def_id
  13:        0x10cf8f3ec - <rustc_middle[6ad8a970aa6bf88a]::ty::context::TyCtxt>::def_path_hash_to_def_id
  14:        0x10cfb4e4c - <rustc_query_system[f65373cf6a3466fe]::dep_graph::dep_node::DepNode<rustc_middle[6ad8a970aa6bf88a]::dep_graph::dep_node::DepKind> as rustc_middle[6ad8a970aa6bf88a]::dep_graph::dep_node::DepNodeExt>::extract_def_id
  15:        0x10c51dfa0 - rustc_query_impl[bef29f7fed8c56d5]::plumbing::force_from_dep_node::<rustc_query_impl[bef29f7fed8c56d5]::queries::type_of>
  16:        0x10cf7aef4 - <rustc_middle[6ad8a970aa6bf88a]::ty::context::TyCtxt as rustc_query_system[f65373cf6a3466fe]::dep_graph::DepContext>::try_force_from_dep_node
  17:        0x10c472cbc - <rustc_query_system[f65373cf6a3466fe]::dep_graph::graph::DepGraph<rustc_middle[6ad8a970aa6bf88a]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[bef29f7fed8c56d5]::plumbing::QueryCtxt>
  18:        0x10c472c8c - <rustc_query_system[f65373cf6a3466fe]::dep_graph::graph::DepGraph<rustc_middle[6ad8a970aa6bf88a]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[bef29f7fed8c56d5]::plumbing::QueryCtxt>
  19:        0x10c472c8c - <rustc_query_system[f65373cf6a3466fe]::dep_graph::graph::DepGraph<rustc_middle[6ad8a970aa6bf88a]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[bef29f7fed8c56d5]::plumbing::QueryCtxt>
  20:        0x10c472c8c - <rustc_query_system[f65373cf6a3466fe]::dep_graph::graph::DepGraph<rustc_middle[6ad8a970aa6bf88a]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[bef29f7fed8c56d5]::plumbing::QueryCtxt>
  21:        0x10c443108 - <rustc_query_system[f65373cf6a3466fe]::dep_graph::graph::DepGraph<rustc_middle[6ad8a970aa6bf88a]::dep_graph::dep_node::DepKind>>::try_mark_green::<rustc_query_impl[bef29f7fed8c56d5]::plumbing::QueryCtxt>
  22:        0x10c2dcb18 - rustc_query_system[f65373cf6a3466fe]::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl[bef29f7fed8c56d5]::plumbing::QueryCtxt, rustc_middle[6ad8a970aa6bf88a]::infer::canonical::Canonical<rustc_middle[6ad8a970aa6bf88a]::ty::ParamEnvAnd<rustc_middle[6ad8a970aa6bf88a]::ty::Predicate>>, core[7341f3703d0d347b]::result::Result<rustc_middle[6ad8a970aa6bf88a]::traits::select::EvaluationResult, rustc_middle[6ad8a970aa6bf88a]::traits::select::OverflowError>>
  23:        0x10c245038 - rustc_query_system[f65373cf6a3466fe]::query::plumbing::try_execute_query::<rustc_query_impl[bef29f7fed8c56d5]::plumbing::QueryCtxt, rustc_query_system[f65373cf6a3466fe]::query::caches::DefaultCache<rustc_middle[6ad8a970aa6bf88a]::infer::canonical::Canonical<rustc_middle[6ad8a970aa6bf88a]::ty::ParamEnvAnd<rustc_middle[6ad8a970aa6bf88a]::ty::Predicate>>, core[7341f3703d0d347b]::result::Result<rustc_middle[6ad8a970aa6bf88a]::traits::select::EvaluationResult, rustc_middle[6ad8a970aa6bf88a]::traits::select::OverflowError>>>
  24:        0x10c30c214 - rustc_query_system[f65373cf6a3466fe]::query::plumbing::get_query::<rustc_query_impl[bef29f7fed8c56d5]::queries::evaluate_obligation, rustc_query_impl[bef29f7fed8c56d5]::plumbing::QueryCtxt>
  25:        0x10c56c008 - <rustc_query_impl[bef29f7fed8c56d5]::Queries as rustc_middle[6ad8a970aa6bf88a]::ty::query::QueryEngine>::evaluate_obligation
  26:        0x10cc98b2c - <rustc_infer[1bcc6eeaa0601f5c]::infer::InferCtxt as rustc_trait_selection[a20044fd431323a2]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
  27:        0x10cc98c14 - <rustc_infer[1bcc6eeaa0601f5c]::infer::InferCtxt as rustc_trait_selection[a20044fd431323a2]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  28:        0x10cd4a8fc - <rustc_trait_selection[a20044fd431323a2]::traits::fulfill::FulfillProcessor>::process_trait_obligation
  29:        0x10cd4a3d8 - <rustc_trait_selection[a20044fd431323a2]::traits::fulfill::FulfillProcessor as rustc_data_structures[309676ed709479c3]::obligation_forest::ObligationProcessor>::process_obligation
  30:        0x10cd0a918 - <rustc_data_structures[309676ed709479c3]::obligation_forest::ObligationForest<rustc_trait_selection[a20044fd431323a2]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[a20044fd431323a2]::traits::fulfill::FulfillProcessor, rustc_data_structures[309676ed709479c3]::obligation_forest::Outcome<rustc_trait_selection[a20044fd431323a2]::traits::fulfill::PendingPredicateObligation, rustc_infer[1bcc6eeaa0601f5c]::traits::FulfillmentErrorCode>>
  31:        0x10cd45d3c - <rustc_trait_selection[a20044fd431323a2]::traits::fulfill::FulfillmentContext as rustc_infer[1bcc6eeaa0601f5c]::traits::engine::TraitEngine>::select_where_possible
  32:        0x10cd45c5c - <rustc_trait_selection[a20044fd431323a2]::traits::fulfill::FulfillmentContext as rustc_infer[1bcc6eeaa0601f5c]::traits::engine::TraitEngine>::select_all_or_error
  33:        0x10cd45214 - <rustc_trait_selection[a20044fd431323a2]::traits::engine::ObligationCtxt>::select_all_or_error
  34:        0x10ba8445c - <rustc_infer[1bcc6eeaa0601f5c]::infer::InferCtxtBuilder>::enter::<(), rustc_typeck[a5d00582971cd053]::check::wfcheck::enter_wf_checking_ctxt<rustc_typeck[a5d00582971cd053]::check::wfcheck::check_impl::{closure#0}>::{closure#0}>
  35:        0x10ba38718 - rustc_typeck[a5d00582971cd053]::check::wfcheck::check_well_formed
  36:        0x10c486344 - <rustc_query_system[f65373cf6a3466fe]::dep_graph::graph::DepGraph<rustc_middle[6ad8a970aa6bf88a]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[6ad8a970aa6bf88a]::ty::context::TyCtxt, rustc_span[81520514b41fb732]::def_id::LocalDefId, ()>
  37:        0x10c25fa88 - rustc_query_system[f65373cf6a3466fe]::query::plumbing::try_execute_query::<rustc_query_impl[bef29f7fed8c56d5]::plumbing::QueryCtxt, rustc_query_system[f65373cf6a3466fe]::query::caches::DefaultCache<rustc_span[81520514b41fb732]::def_id::LocalDefId, ()>>
  38:        0x10c30992c - rustc_query_system[f65373cf6a3466fe]::query::plumbing::get_query::<rustc_query_impl[bef29f7fed8c56d5]::queries::check_well_formed, rustc_query_impl[bef29f7fed8c56d5]::plumbing::QueryCtxt>
  39:        0x10b9d9dec - rustc_data_structures[309676ed709479c3]::sync::par_for_each_in::<&[rustc_hir[f788c0200d65aab0]::hir::ItemId], <rustc_middle[6ad8a970aa6bf88a]::hir::ModuleItems>::par_items<rustc_typeck[a5d00582971cd053]::check::wfcheck::check_mod_type_wf::{closure#0}>::{closure#0}>
  40:        0x10ba3e768 - rustc_typeck[a5d00582971cd053]::check::wfcheck::check_mod_type_wf
  41:        0x10c486344 - <rustc_query_system[f65373cf6a3466fe]::dep_graph::graph::DepGraph<rustc_middle[6ad8a970aa6bf88a]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[6ad8a970aa6bf88a]::ty::context::TyCtxt, rustc_span[81520514b41fb732]::def_id::LocalDefId, ()>
  42:        0x10c25fa88 - rustc_query_system[f65373cf6a3466fe]::query::plumbing::try_execute_query::<rustc_query_impl[bef29f7fed8c56d5]::plumbing::QueryCtxt, rustc_query_system[f65373cf6a3466fe]::query::caches::DefaultCache<rustc_span[81520514b41fb732]::def_id::LocalDefId, ()>>
  43:        0x10c3097f0 - rustc_query_system[f65373cf6a3466fe]::query::plumbing::get_query::<rustc_query_impl[bef29f7fed8c56d5]::queries::check_mod_type_wf, rustc_query_impl[bef29f7fed8c56d5]::plumbing::QueryCtxt>
  44:        0x10b9d9a5c - rustc_data_structures[309676ed709479c3]::sync::par_for_each_in::<&[rustc_span[81520514b41fb732]::def_id::LocalDefId], <rustc_middle[6ad8a970aa6bf88a]::hir::map::Map>::par_for_each_module<rustc_typeck[a5d00582971cd053]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>
  45:        0x10b9863d8 - <rustc_session[11f94df6f0b47447]::session::Session>::track_errors::<rustc_typeck[a5d00582971cd053]::check_crate::{closure#5}, ()>
  46:        0x10baa5acc - rustc_typeck[a5d00582971cd053]::check_crate
  47:        0x1093e6830 - rustc_interface[2fa9866cf3cf12fa]::passes::analysis
  48:        0x10c4a87dc - <rustc_query_system[f65373cf6a3466fe]::dep_graph::graph::DepGraph<rustc_middle[6ad8a970aa6bf88a]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[6ad8a970aa6bf88a]::ty::context::TyCtxt, (), core[7341f3703d0d347b]::result::Result<(), rustc_errors[e87086a6cb9e4ec1]::ErrorGuaranteed>>
  49:        0x10c2b52d0 - rustc_query_system[f65373cf6a3466fe]::query::plumbing::try_execute_query::<rustc_query_impl[bef29f7fed8c56d5]::plumbing::QueryCtxt, rustc_query_system[f65373cf6a3466fe]::query::caches::DefaultCache<(), core[7341f3703d0d347b]::result::Result<(), rustc_errors[e87086a6cb9e4ec1]::ErrorGuaranteed>>>
  50:        0x10c31c92c - rustc_query_system[f65373cf6a3466fe]::query::plumbing::get_query::<rustc_query_impl[bef29f7fed8c56d5]::queries::analysis, rustc_query_impl[bef29f7fed8c56d5]::plumbing::QueryCtxt>
  51:        0x1093066f0 - <rustc_interface[2fa9866cf3cf12fa]::passes::QueryContext>::enter::<rustc_driver[51b00cac61f89616]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[7341f3703d0d347b]::result::Result<(), rustc_errors[e87086a6cb9e4ec1]::ErrorGuaranteed>>
  52:        0x1092db704 - rustc_interface[2fa9866cf3cf12fa]::interface::create_compiler_and_run::<core[7341f3703d0d347b]::result::Result<(), rustc_errors[e87086a6cb9e4ec1]::ErrorGuaranteed>, rustc_driver[51b00cac61f89616]::run_compiler::{closure#1}>
  53:        0x1093407d4 - <scoped_tls[e8bbfd374be19a85]::ScopedKey<rustc_span[81520514b41fb732]::SessionGlobals>>::set::<rustc_interface[2fa9866cf3cf12fa]::interface::run_compiler<core[7341f3703d0d347b]::result::Result<(), rustc_errors[e87086a6cb9e4ec1]::ErrorGuaranteed>, rustc_driver[51b00cac61f89616]::run_compiler::{closure#1}>::{closure#0}, core[7341f3703d0d347b]::result::Result<(), rustc_errors[e87086a6cb9e4ec1]::ErrorGuaranteed>>
  54:        0x10930a464 - std[65493a5d9e125887]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[2fa9866cf3cf12fa]::util::run_in_thread_pool_with_globals<rustc_interface[2fa9866cf3cf12fa]::interface::run_compiler<core[7341f3703d0d347b]::result::Result<(), rustc_errors[e87086a6cb9e4ec1]::ErrorGuaranteed>, rustc_driver[51b00cac61f89616]::run_compiler::{closure#1}>::{closure#0}, core[7341f3703d0d347b]::result::Result<(), rustc_errors[e87086a6cb9e4ec1]::ErrorGuaranteed>>::{closure#0}, core[7341f3703d0d347b]::result::Result<(), rustc_errors[e87086a6cb9e4ec1]::ErrorGuaranteed>>
  55:        0x10930d2e8 - <<std[65493a5d9e125887]::thread::Builder>::spawn_unchecked_<rustc_interface[2fa9866cf3cf12fa]::util::run_in_thread_pool_with_globals<rustc_interface[2fa9866cf3cf12fa]::interface::run_compiler<core[7341f3703d0d347b]::result::Result<(), rustc_errors[e87086a6cb9e4ec1]::ErrorGuaranteed>, rustc_driver[51b00cac61f89616]::run_compiler::{closure#1}>::{closure#0}, core[7341f3703d0d347b]::result::Result<(), rustc_errors[e87086a6cb9e4ec1]::ErrorGuaranteed>>::{closure#0}, core[7341f3703d0d347b]::result::Result<(), rustc_errors[e87086a6cb9e4ec1]::ErrorGuaranteed>>::{closure#1} as core[7341f3703d0d347b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  56:        0x10156e550 - std::sys::unix::thread::Thread::new::thread_start::h24b04cb1ad6e937f
  57:        0x1870a426c - __pthread_deallocate
```

</p>
</details>