Repository: rust
Issue: Compilation suddenly stopped working; Cargo clean fixed the problem
Labels: I-ICE,T-compiler,A-incr-comp,C-bug

<!--
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/

-->

Compilation suddenly stopped working. Rustc only reported the error below on every compilation attempt. I messed around with a rather complex trait involving many (16 at the moment) associated types.
After running `cargo clean` and rebuilding the project from scratch, the application compiled again and ran as good as always.


### Code

```Rust
// As the code is not open-sourced, I cannot share an example. I just hope that the log output alone can help a tiny bit.
```


### 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.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: aarch64-apple-darwin
release: 1.63.0
LLVM version: 14.0.5
```

### Error output

```
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_metadata/src/rmeta/def_path_hash_map.rs:23:85
stack backtrace:
   0:        0x10334ffe0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h188b7ef1c7993e78
   1:        0x1033a1a54 - core::fmt::write::he84a3004e7af3f34
   2:        0x1033430c0 - std::io::Write::write_fmt::h9370b50affaab0be
   3:        0x103352c24 - std::panicking::default_hook::{{closure}}::hc074f8023cce83ca
   4:        0x10335298c - std::panicking::default_hook::hef854b51b9b79ff2
   5:        0x10a7c0154 - rustc_driver[8d2050f8429f7bc4]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:        0x1033531f8 - std::panicking::rust_panic_with_hook::h1e59e224d558a492
   7:        0x103353058 - std::panicking::begin_panic_handler::{{closure}}::he1a9d6ab32bfd8c6
   8:        0x1033504bc - std::sys_common::backtrace::__rust_end_short_backtrace::he9b94791b02f48cd
   9:        0x103352de8 - _rust_begin_unwind
  10:        0x1033cf968 - core::panicking::panic_fmt::h9fec86f6a9c4146e
  11:        0x1033cf888 - core::panicking::panic::h02e9fc642940f2ec
  12:        0x10db495f4 - <rustc_metadata[10f669a6330283ac]::creader::CStore as rustc_session[282d64e95cd3bf88]::cstore::CrateStore>::def_path_hash_to_def_id
  13:        0x10e2eeb6c - <rustc_middle[4fa9dd76776bb2aa]::ty::context::TyCtxt>::def_path_hash_to_def_id
  14:        0x10e20be8c - <rustc_query_system[f18d9eae22d44560]::dep_graph::dep_node::DepNode<rustc_middle[4fa9dd76776bb2aa]::dep_graph::dep_node::DepKind> as rustc_middle[4fa9dd76776bb2aa]::dep_graph::dep_node::DepNodeExt>::extract_def_id
  15:        0x10d898c34 - rustc_query_impl[d9716e6ec5023784]::query_callbacks::type_of::force_from_dep_node
  16:        0x10e2d9c70 - <rustc_middle[4fa9dd76776bb2aa]::ty::context::TyCtxt as rustc_query_system[f18d9eae22d44560]::dep_graph::DepContext>::try_force_from_dep_node
  17:        0x10d7aa8a4 - <rustc_query_system[f18d9eae22d44560]::dep_graph::graph::DepGraph<rustc_middle[4fa9dd76776bb2aa]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt>
  18:        0x10d7aa874 - <rustc_query_system[f18d9eae22d44560]::dep_graph::graph::DepGraph<rustc_middle[4fa9dd76776bb2aa]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt>
  19:        0x10d7aa874 - <rustc_query_system[f18d9eae22d44560]::dep_graph::graph::DepGraph<rustc_middle[4fa9dd76776bb2aa]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt>
  20:        0x10d7aa874 - <rustc_query_system[f18d9eae22d44560]::dep_graph::graph::DepGraph<rustc_middle[4fa9dd76776bb2aa]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt>
  21:        0x10d7aa874 - <rustc_query_system[f18d9eae22d44560]::dep_graph::graph::DepGraph<rustc_middle[4fa9dd76776bb2aa]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt>
  22:        0x10d7aa874 - <rustc_query_system[f18d9eae22d44560]::dep_graph::graph::DepGraph<rustc_middle[4fa9dd76776bb2aa]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt>
  23:        0x10d7aa874 - <rustc_query_system[f18d9eae22d44560]::dep_graph::graph::DepGraph<rustc_middle[4fa9dd76776bb2aa]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt>
  24:        0x10d7aa874 - <rustc_query_system[f18d9eae22d44560]::dep_graph::graph::DepGraph<rustc_middle[4fa9dd76776bb2aa]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt>
  25:        0x10d5da528 - rustc_query_system[f18d9eae22d44560]::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt, rustc_middle[4fa9dd76776bb2aa]::infer::canonical::Canonical<rustc_middle[4fa9dd76776bb2aa]::ty::ParamEnvAnd<rustc_middle[4fa9dd76776bb2aa]::ty::Predicate>>, core[bae5e8ef542d20e5]::result::Result<rustc_middle[4fa9dd76776bb2aa]::traits::select::EvaluationResult, rustc_middle[4fa9dd76776bb2aa]::traits::select::OverflowError>>
  26:        0x10d61fa08 - rustc_query_system[f18d9eae22d44560]::query::plumbing::get_query::<rustc_query_impl[d9716e6ec5023784]::queries::evaluate_obligation, rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt>
  27:        0x10d894b2c - <rustc_query_impl[d9716e6ec5023784]::Queries as rustc_middle[4fa9dd76776bb2aa]::ty::query::QueryEngine>::evaluate_obligation
  28:        0x10df98de8 - <rustc_infer[b8df2f762d2af832]::infer::InferCtxt as rustc_trait_selection[3c6344c85e89bbc6]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
  29:        0x10df98ed4 - <rustc_infer[b8df2f762d2af832]::infer::InferCtxt as rustc_trait_selection[3c6344c85e89bbc6]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  30:        0x10e0038fc - <rustc_trait_selection[3c6344c85e89bbc6]::traits::fulfill::FulfillProcessor>::process_trait_obligation
  31:        0x10dffddac - <rustc_trait_selection[3c6344c85e89bbc6]::traits::fulfill::FulfillProcessor as rustc_data_structures[d06618763e7f5cde]::obligation_forest::ObligationProcessor>::process_obligation
  32:        0x10e049b64 - <rustc_data_structures[d06618763e7f5cde]::obligation_forest::ObligationForest<rustc_trait_selection[3c6344c85e89bbc6]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[3c6344c85e89bbc6]::traits::fulfill::FulfillProcessor, rustc_data_structures[d06618763e7f5cde]::obligation_forest::Outcome<rustc_trait_selection[3c6344c85e89bbc6]::traits::fulfill::PendingPredicateObligation, rustc_infer[b8df2f762d2af832]::traits::FulfillmentErrorCode>>
  33:        0x10dffd714 - <rustc_trait_selection[3c6344c85e89bbc6]::traits::fulfill::FulfillmentContext as rustc_infer[b8df2f762d2af832]::traits::engine::TraitEngine>::select_where_possible
  34:        0x10cc42154 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_argument_types
  35:        0x10cc25d94 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::confirm_builtin_call
  36:        0x10cc23e68 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_call
  37:        0x10cc73574 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_expr_kind
  38:        0x10cc34cc8 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  39:        0x10cc46a68 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#0}
  40:        0x10cc420e0 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_argument_types
  41:        0x10cc41848 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_method_argument_types
  42:        0x10cc74d24 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_expr_kind
  43:        0x10cc34cc8 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  44:        0x10cc76af4 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_expr_kind
  45:        0x10cc34cc8 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  46:        0x10cc47ab8 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_stmt
  47:        0x10cc4810c - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_block_with_expected
  48:        0x10cc73768 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_expr_kind
  49:        0x10cc34cc8 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  50:        0x10cc35980 - <rustc_typeck[dc6010940c7a2a65]::check::fn_ctxt::FnCtxt>::check_return_expr
  51:        0x10ccc934c - rustc_typeck[dc6010940c7a2a65]::check::check::check_fn
  52:        0x10cd92e5c - <rustc_infer[b8df2f762d2af832]::infer::InferCtxtBuilder>::enter::<&rustc_middle[4fa9dd76776bb2aa]::ty::context::TypeckResults, <rustc_typeck[dc6010940c7a2a65]::check::inherited::InheritedBuilder>::enter<rustc_typeck[dc6010940c7a2a65]::check::typeck_with_fallback<rustc_typeck[dc6010940c7a2a65]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[4fa9dd76776bb2aa]::ty::context::TypeckResults>::{closure#0}>
  53:        0x10cd17970 - rustc_typeck[dc6010940c7a2a65]::check::typeck
  54:        0x10d7bb684 - <rustc_query_system[f18d9eae22d44560]::dep_graph::graph::DepGraph<rustc_middle[4fa9dd76776bb2aa]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[4fa9dd76776bb2aa]::ty::context::TyCtxt, rustc_span[143ffa354e326ede]::def_id::LocalDefId, &rustc_middle[4fa9dd76776bb2aa]::ty::context::TypeckResults>
  55:        0x10d57a388 - rustc_query_system[f18d9eae22d44560]::query::plumbing::try_execute_query::<rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt, rustc_query_system[f18d9eae22d44560]::query::caches::DefaultCache<rustc_span[143ffa354e326ede]::def_id::LocalDefId, &rustc_middle[4fa9dd76776bb2aa]::ty::context::TypeckResults>>
  56:        0x10d64f0f8 - rustc_query_system[f18d9eae22d44560]::query::plumbing::get_query::<rustc_query_impl[d9716e6ec5023784]::queries::typeck, rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt>
  57:        0x10cdfe0fc - <rustc_middle[4fa9dd76776bb2aa]::hir::map::Map>::par_body_owners::<rustc_typeck[dc6010940c7a2a65]::check::typeck_item_bodies::{closure#0}>
  58:        0x10cd1b9c0 - rustc_typeck[dc6010940c7a2a65]::check::typeck_item_bodies
  59:        0x10d7e38e0 - <rustc_query_system[f18d9eae22d44560]::dep_graph::graph::DepGraph<rustc_middle[4fa9dd76776bb2aa]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[4fa9dd76776bb2aa]::ty::context::TyCtxt, (), ()>
  60:        0x10d5bb5e0 - rustc_query_system[f18d9eae22d44560]::query::plumbing::try_execute_query::<rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt, rustc_query_system[f18d9eae22d44560]::query::caches::DefaultCache<(), ()>>
  61:        0x10d61ee08 - rustc_query_system[f18d9eae22d44560]::query::plumbing::get_query::<rustc_query_impl[d9716e6ec5023784]::queries::typeck_item_bodies, rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt>
  62:        0x10cdfd964 - <rustc_session[282d64e95cd3bf88]::session::Session>::time::<(), rustc_typeck[dc6010940c7a2a65]::check_crate::{closure#7}>
  63:        0x10cd86368 - rustc_typeck[dc6010940c7a2a65]::check_crate
  64:        0x10a84bf24 - rustc_interface[db32075e2a9c594e]::passes::analysis
  65:        0x10d7dbb48 - <rustc_query_system[f18d9eae22d44560]::dep_graph::graph::DepGraph<rustc_middle[4fa9dd76776bb2aa]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[4fa9dd76776bb2aa]::ty::context::TyCtxt, (), core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>>
  66:        0x10d5b05d0 - rustc_query_system[f18d9eae22d44560]::query::plumbing::try_execute_query::<rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt, rustc_query_system[f18d9eae22d44560]::query::caches::DefaultCache<(), core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>>>
  67:        0x10d64f54c - rustc_query_system[f18d9eae22d44560]::query::plumbing::get_query::<rustc_query_impl[d9716e6ec5023784]::queries::analysis, rustc_query_impl[d9716e6ec5023784]::plumbing::QueryCtxt>
  68:        0x10a78266c - <rustc_interface[db32075e2a9c594e]::passes::QueryContext>::enter::<rustc_driver[8d2050f8429f7bc4]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>>
  69:        0x10a7657f0 - <rustc_interface[db32075e2a9c594e]::interface::Compiler>::enter::<rustc_driver[8d2050f8429f7bc4]::run_compiler::{closure#1}::{closure#2}, core[bae5e8ef542d20e5]::result::Result<core[bae5e8ef542d20e5]::option::Option<rustc_interface[db32075e2a9c594e]::queries::Linker>, rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>>
  70:        0x10a751bb4 - rustc_span[143ffa354e326ede]::with_source_map::<core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>, rustc_interface[db32075e2a9c594e]::interface::create_compiler_and_run<core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>, rustc_driver[8d2050f8429f7bc4]::run_compiler::{closure#1}>::{closure#1}>
  71:        0x10a765fe8 - <scoped_tls[e8c526b3ddc66487]::ScopedKey<rustc_span[143ffa354e326ede]::SessionGlobals>>::set::<rustc_interface[db32075e2a9c594e]::interface::run_compiler<core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>, rustc_driver[8d2050f8429f7bc4]::run_compiler::{closure#1}>::{closure#0}, core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>>
  72:        0x10a7b0b68 - std[ad4c17a2ddbcabe2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[db32075e2a9c594e]::util::run_in_thread_pool_with_globals<rustc_interface[db32075e2a9c594e]::interface::run_compiler<core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>, rustc_driver[8d2050f8429f7bc4]::run_compiler::{closure#1}>::{closure#0}, core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>>::{closure#0}, core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>>
  73:        0x10a784ef8 - <<std[ad4c17a2ddbcabe2]::thread::Builder>::spawn_unchecked_<rustc_interface[db32075e2a9c594e]::util::run_in_thread_pool_with_globals<rustc_interface[db32075e2a9c594e]::interface::run_compiler<core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>, rustc_driver[8d2050f8429f7bc4]::run_compiler::{closure#1}>::{closure#0}, core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>>::{closure#0}, core[bae5e8ef542d20e5]::result::Result<(), rustc_errors[3321b68084f70bb0]::ErrorGuaranteed>>::{closure#1} as core[bae5e8ef542d20e5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  74:        0x10335ba5c - std::sys::unix::thread::Thread::new::thread_start::h7b2f9b83fb320a20
  75:        0x1a7f1026c - __pthread_deallocate

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.63.0 (4b91a6ea7 2022-08-08) running on aarch64-apple-darwin

note: compiler flags: --crate-type bin -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `impl core::future::future::Future<Output = core::result::Result<crud_shared_types::SaveResult<<crud_resources::CrudClusterResource as crud_rs::resource::CrudResource>::Model>, crud_shared_types::CrudError>>: core::marker::Send`  |  = note: this failure-note originates in the macro `impl_add_crud_routes` (in Nightly builds, run with -Z macro-backtrace for more info)

#1 [typeck] type-checking `router::axum_clusters_crud_routes::add_crud_routes`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `fcs-server`
[Finished running. Exit status: 101]
```

<!--
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>

I am sadly unable to reproduce the error and rebuild the app with the backtrace env flag set..

</p>
</details>