Repository: rust
Issue: ICE: called `Option::unwrap()` on a `None` value in `compiler/rustc_metadata/src/rmeta/def_path_hash_map.rs:23:54`
Labels: I-ICE,T-compiler,A-incr-comp,C-bug,S-needs-repro

<!--
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/
-->

### Code

The project that I'm working on is proprietary so I can't share the code. I've attempted to produce a minification of the issue but the error seems to be related to incremental compilation and goes away once I `cargo clean`.

This issue seems to be similar to #130283


### 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.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7
```

### Error output

Note that some of the module paths are obfuscated with `wow` and `more` to conceal proprietary details about the project I'm working on.

```
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.81.0 (eeb90cda1 2024-09-04) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -C link-arg=-fuse-ld=mold

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

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `{coroutine witness@dynamo_builder::get_item::__GetItem<<wow::status::index::PrimaryKey as dynamo_builder::item::ItemIndex>::Item, wow::status::index::PrimaryKey>::send<wow::dispatch::EnumDynService<wow::MockDynamoClient, wow::DynamoClientAws>>::{closure#0}}: core::marker::Send`
#1 [collect_return_position_impl_trait_in_trait_tys] comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process
#2 [analysis] running analysis passes on this crate
end of query stack
there was a panic while trying to force a dep node
try_mark_green dep node stack:
#0 TraitSelect(286a9d81e5cbae84-bdb37ffdbbaf227f)
#1 TraitSelect(c29395a6bf241d93-8c74c3395c7563de)
#2 TraitSelect(9743252cb57de17d-25fc48a813117487)
#3 TraitSelect(b6ea8fa4c4188ac5-7dd3406424ac7b93)
#4 evaluate_obligation(ec38fdc9259ee8c7-4e86ba006a372163)
end of try_mark_green dep node stack
there was a panic while trying to force a dep node
try_mark_green dep node stack:
#0 type_of(wow[b400]::wow::_::{impl#2}::{synthetic#0})
#1 check_well_formed(wow[b400]::wow::_::{impl#2})
#2 check_mod_type_wf(wow[b400]::wow::more)
end of try_mark_green dep node 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 compiler/rustc_metadata/src/rmeta/def_path_hash_map.rs:23:54:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7fb53975e3e5 - std::backtrace_rs::backtrace::libunwind::trace::h649ab3318d3445c5
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7fb53975e3e5 - std::backtrace_rs::backtrace::trace_unsynchronized::hf4bb60c3387150c3
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb53975e3e5 - std::sys::backtrace::_print_fmt::hd9186c800e44bd00
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:65:5
   3:     0x7fb53975e3e5 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1b9dad2a88e955ff
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:40:26
   4:     0x7fb5397adeeb - core::fmt::rt::Argument::fmt::h351a7824f737a6a0
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/fmt/rt.rs:173:76
   5:     0x7fb5397adeeb - core::fmt::write::h4b5a1270214bc4a7
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/fmt/mod.rs:1182:21
   6:     0x7fb539752f6f - std::io::Write::write_fmt::hd04af345a50c312d
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/io/mod.rs:1827:15
   7:     0x7fb539760bd1 - std::sys::backtrace::BacktraceLock::print::h68d41b51481bce5c
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:43:9
   8:     0x7fb539760bd1 - std::panicking::default_hook::{{closure}}::h96ab15e9936be7ed
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:269:22
   9:     0x7fb5397608ac - std::panicking::default_hook::h3cacb9c27561ad33
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:296:9
  10:     0x7fb53ca93420 - std[1f2242ed6435445e]::panicking::update_hook::<alloc[7b1462a1eb55c293]::boxed::Box<rustc_driver_impl[8683aa37472b7dde]::install_ice_hook::{closure#0}>>::{closure#0}
  11:     0x7fb53976159f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hce7569f4ca5d1b64
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/alloc/src/boxed.rs:2084:9
  12:     0x7fb53976159f - std::panicking::rust_panic_with_hook::hfe205f6954b2c97b
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:808:13
  13:     0x7fb539761193 - std::panicking::begin_panic_handler::{{closure}}::h6cb44b3a50f28c44
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:667:13
  14:     0x7fb53975e8a9 - std::sys::backtrace::__rust_end_short_backtrace::hf1c1f2a92799bb0e
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:168:18
  15:     0x7fb539760e54 - rust_begin_unwind
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:665:5
  16:     0x7fb5397aa4a3 - core::panicking::panic_fmt::h3d8fc78294164da7
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:74:14
  17:     0x7fb5397aa52c - core::panicking::panic::hec978767ec2d35ff
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:148:5
  18:     0x7fb5397aa299 - core::option::unwrap_failed::hba6b08832f9ce30b
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/option.rs:2020:5
  19:     0x7fb53e11ed40 - <rustc_query_system[200ca28aa7d9732c]::dep_graph::dep_node::DepNode as rustc_middle[ba2289ab3ae064d4]::dep_graph::dep_node::DepNodeExt>::extract_def_id
  20:     0x7fb53ece3cdf - rustc_query_impl[3625cc0592f96219]::plumbing::force_from_dep_node::<rustc_query_impl[3625cc0592f96219]::DynamicConfig<rustc_query_system[200ca28aa7d9732c]::query::caches::DefIdCache<rustc_middle[ba2289ab3ae064d4]::query::erase::Erased<[u8; 8usize]>>, false, false, false>>
  21:     0x7fb53ece3bad - <rustc_query_impl[3625cc0592f96219]::plumbing::query_callback<rustc_query_impl[3625cc0592f96219]::query_impl::type_of::QueryType>::{closure#0} as core[3cad2706d8bdcdc4]::ops::function::FnOnce<(rustc_middle[ba2289ab3ae064d4]::ty::context::TyCtxt, rustc_query_system[200ca28aa7d9732c]::dep_graph::dep_node::DepNode)>>::call_once
  22:     0x7fb53e2f7f4b - <rustc_query_system[200ca28aa7d9732c]::dep_graph::graph::DepGraphData<rustc_middle[ba2289ab3ae064d4]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[3625cc0592f96219]::plumbing::QueryCtxt>
  23:     0x7fb53e2f7ec0 - <rustc_query_system[200ca28aa7d9732c]::dep_graph::graph::DepGraphData<rustc_middle[ba2289ab3ae064d4]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[3625cc0592f96219]::plumbing::QueryCtxt>
  24:     0x7fb53e2f7ec0 - <rustc_query_system[200ca28aa7d9732c]::dep_graph::graph::DepGraphData<rustc_middle[ba2289ab3ae064d4]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[3625cc0592f96219]::plumbing::QueryCtxt>
  25:     0x7fb53e2f7ec0 - <rustc_query_system[200ca28aa7d9732c]::dep_graph::graph::DepGraphData<rustc_middle[ba2289ab3ae064d4]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[3625cc0592f96219]::plumbing::QueryCtxt>
  26:     0x7fb53e2f7ec0 - <rustc_query_system[200ca28aa7d9732c]::dep_graph::graph::DepGraphData<rustc_middle[ba2289ab3ae064d4]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[3625cc0592f96219]::plumbing::QueryCtxt>
  27:     0x7fb53e4e8993 - rustc_query_system[200ca28aa7d9732c]::query::plumbing::try_execute_query::<rustc_query_impl[3625cc0592f96219]::DynamicConfig<rustc_query_system[200ca28aa7d9732c]::query::caches::DefaultCache<rustc_type_ir[6247808700e50c64]::canonical::Canonical<rustc_middle[ba2289ab3ae064d4]::ty::context::TyCtxt, rustc_middle[ba2289ab3ae064d4]::ty::ParamEnvAnd<rustc_middle[ba2289ab3ae064d4]::ty::predicate::Predicate>>, rustc_middle[ba2289ab3ae064d4]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[3625cc0592f96219]::plumbing::QueryCtxt, true>
  28:     0x7fb53e4e71f3 - rustc_query_impl[3625cc0592f96219]::query_impl::evaluate_obligation::get_query_incr::__rust_end_short_backtrace
  29:     0x7fb53a9daab6 - <rustc_trait_selection[f6fdd9b289c162ed]::traits::fulfill::FulfillProcessor as rustc_data_structures[925c538e020d714]::obligation_forest::ObligationProcessor>::process_obligation
  30:     0x7fb53e1caf91 - <rustc_data_structures[925c538e020d714]::obligation_forest::ObligationForest<rustc_trait_selection[f6fdd9b289c162ed]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[f6fdd9b289c162ed]::traits::fulfill::FulfillProcessor>
  31:     0x7fb53e1ca32d - <rustc_trait_selection[f6fdd9b289c162ed]::traits::fulfill::FulfillmentContext<rustc_trait_selection[f6fdd9b289c162ed]::traits::FulfillmentError> as rustc_infer[ee9f1d9e94c94b4a]::traits::engine::TraitEngine<rustc_trait_selection[f6fdd9b289c162ed]::traits::FulfillmentError>>::select_all_or_error
  32:     0x7fb53cc41719 - rustc_hir_analysis[c1a678e360ecab51]::check::compare_impl_item::collect_return_position_impl_trait_in_trait_tys::{closure#0}
  33:     0x7fb53d45fdc3 - rustc_query_impl[3625cc0592f96219]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3625cc0592f96219]::query_impl::collect_return_position_impl_trait_in_trait_tys::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ba2289ab3ae064d4]::query::erase::Erased<[u8; 8usize]>>
  34:     0x7fb53e2f097c - rustc_query_system[200ca28aa7d9732c]::query::plumbing::try_execute_query::<rustc_query_impl[3625cc0592f96219]::DynamicConfig<rustc_query_system[200ca28aa7d9732c]::query::caches::DefIdCache<rustc_middle[ba2289ab3ae064d4]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[3625cc0592f96219]::plumbing::QueryCtxt, true>
  35:     0x7fb53ece3db4 - rustc_query_impl[3625cc0592f96219]::plumbing::force_from_dep_node::<rustc_query_impl[3625cc0592f96219]::DynamicConfig<rustc_query_system[200ca28aa7d9732c]::query::caches::DefIdCache<rustc_middle[ba2289ab3ae064d4]::query::erase::Erased<[u8; 8usize]>>, false, false, false>>
  36:     0x7fb53d42c50d - <rustc_query_impl[3625cc0592f96219]::plumbing::query_callback<rustc_query_impl[3625cc0592f96219]::query_impl::collect_return_position_impl_trait_in_trait_tys::QueryType>::{closure#0} as core[3cad2706d8bdcdc4]::ops::function::FnOnce<(rustc_middle[ba2289ab3ae064d4]::ty::context::TyCtxt, rustc_query_system[200ca28aa7d9732c]::dep_graph::dep_node::DepNode)>>::call_once
  37:     0x7fb53e2f7f4b - <rustc_query_system[200ca28aa7d9732c]::dep_graph::graph::DepGraphData<rustc_middle[ba2289ab3ae064d4]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[3625cc0592f96219]::plumbing::QueryCtxt>
  38:     0x7fb53e2f7ec0 - <rustc_query_system[200ca28aa7d9732c]::dep_graph::graph::DepGraphData<rustc_middle[ba2289ab3ae064d4]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[3625cc0592f96219]::plumbing::QueryCtxt>
  39:     0x7fb53e2f7ec0 - <rustc_query_system[200ca28aa7d9732c]::dep_graph::graph::DepGraphData<rustc_middle[ba2289ab3ae064d4]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[3625cc0592f96219]::plumbing::QueryCtxt>
  40:     0x7fb53e81cfa8 - <rustc_query_system[200ca28aa7d9732c]::dep_graph::graph::DepGraphData<rustc_middle[ba2289ab3ae064d4]::dep_graph::DepsType>>::try_mark_green::<rustc_query_impl[3625cc0592f96219]::plumbing::QueryCtxt>
  41:     0x7fb53e81ca7d - rustc_query_system[200ca28aa7d9732c]::query::plumbing::ensure_must_run::<rustc_query_impl[3625cc0592f96219]::DynamicConfig<rustc_query_system[200ca28aa7d9732c]::query::caches::DefaultCache<rustc_span[28a649581f99a5bd]::def_id::LocalModDefId, rustc_middle[ba2289ab3ae064d4]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[3625cc0592f96219]::plumbing::QueryCtxt>
  42:     0x7fb53e81f660 - rustc_query_impl[3625cc0592f96219]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace
  43:     0x7fb53e240519 - rustc_hir_analysis[c1a678e360ecab51]::check_crate
  44:     0x7fb53e810be6 - rustc_interface[53a414ae04dc6ffb]::passes::analysis
  45:     0x7fb53e8105e7 - rustc_query_impl[3625cc0592f96219]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3625cc0592f96219]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ba2289ab3ae064d4]::query::erase::Erased<[u8; 1usize]>>
  46:     0x7fb53f09c18b - rustc_query_system[200ca28aa7d9732c]::query::plumbing::try_execute_query::<rustc_query_impl[3625cc0592f96219]::DynamicConfig<rustc_query_system[200ca28aa7d9732c]::query::caches::SingleCache<rustc_middle[ba2289ab3ae064d4]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[3625cc0592f96219]::plumbing::QueryCtxt, true>
  47:     0x7fb53f09be78 - rustc_query_impl[3625cc0592f96219]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  48:     0x7fb53ed2c256 - rustc_interface[53a414ae04dc6ffb]::interface::run_compiler::<core[3cad2706d8bdcdc4]::result::Result<(), rustc_span[28a649581f99a5bd]::ErrorGuaranteed>, rustc_driver_impl[8683aa37472b7dde]::run_compiler::{closure#0}>::{closure#1}
  49:     0x7fb53ec7395b - std[1f2242ed6435445e]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[53a414ae04dc6ffb]::util::run_in_thread_with_globals<rustc_interface[53a414ae04dc6ffb]::interface::run_compiler<core[3cad2706d8bdcdc4]::result::Result<(), rustc_span[28a649581f99a5bd]::ErrorGuaranteed>, rustc_driver_impl[8683aa37472b7dde]::run_compiler::{closure#0}>::{closure#1}, core[3cad2706d8bdcdc4]::result::Result<(), rustc_span[28a649581f99a5bd]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3cad2706d8bdcdc4]::result::Result<(), rustc_span[28a649581f99a5bd]::ErrorGuaranteed>>
  50:     0x7fb53ec7372a - <<std[1f2242ed6435445e]::thread::Builder>::spawn_unchecked_<rustc_interface[53a414ae04dc6ffb]::util::run_in_thread_with_globals<rustc_interface[53a414ae04dc6ffb]::interface::run_compiler<core[3cad2706d8bdcdc4]::result::Result<(), rustc_span[28a649581f99a5bd]::ErrorGuaranteed>, rustc_driver_impl[8683aa37472b7dde]::run_compiler::{closure#0}>::{closure#1}, core[3cad2706d8bdcdc4]::result::Result<(), rustc_span[28a649581f99a5bd]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3cad2706d8bdcdc4]::result::Result<(), rustc_span[28a649581f99a5bd]::ErrorGuaranteed>>::{closure#1} as core[3cad2706d8bdcdc4]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  51:     0x7fb53976b5fb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha1963004222e7822
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/alloc/src/boxed.rs:2070:9
  52:     0x7fb53976b5fb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1086ced1f7c494c2
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/alloc/src/boxed.rs:2070:9
  53:     0x7fb53976b5fb - std::sys::pal::unix::thread::Thread::new::thread_start::ha8af9c992ef0b208
                               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/pal/unix/thread.rs:108:17
  54:     0x7fb539545272 - start_thread
  55:     0x7fb5395c0dec - clone3
  56:                0x0 - <unknown>
```

</p>
</details>