Repository: rust
Issue: Compiler error happening regularly after using `cargo sqlx prepare` command
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
What I did is running `cargo sqlx prepare` command, than changed branch with merge.
Next, a docker image was compiled on a server without any problems.
I've changed branch back to test a `/health` check bug running `cargo run` and than this happended.


```Rust
cargo run 
// error
cargo run --target aarch64-apple-darwin
    Finished dev [unoptimized + debuginfo] target(s) in 0.14s
     Running `target/aarch64-apple-darwin/debug/backend`
2022-12-03T14:22:27.701659Z  INFO backend: listening on 127.0.0.1:3000
```
It's weird because `aarch64-apple-darwin` is my default target, error trace shows same target on `cargo run`.
           
### 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)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: aarch64-apple-darwin
release: 1.65.0
LLVM version: 15.0.0
```

### Error output

```
thread 'rustc' panicked at 'Failed to extract DefId: 
local_def_id_to_hir_id cb39f3a9147bac67-2b0991f8d87e9526', 
compiler/rustc_middle/src/dep_graph/dep_node.rs:267:17
```

<!--
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:        0x10118f670 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2990a6f24ccff6db
   1:        0x1011d9c34 - core::fmt::write::h91497fd291c8b104
   2:        0x101182604 - std::io::Write::write_fmt::h23fa41342cffacf4
   3:        0x101191eec - std::panicking::default_hook::{{closure}}::hb41cdb784f4c17ac
   4:        0x101191c10 - std::panicking::default_hook::hdfe992d5fb29a991
   5:        0x108ef6718 - rustc_driver[250dcea03822790c]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:        0x1011925b0 - std::panicking::rust_panic_with_hook::h2eb0e4b718773521
   7:        0x10119245c - std::panicking::begin_panic_handler::{{closure}}::h06a693206403b4d5
   8:        0x10118fad8 - std::sys_common::backtrace::__rust_end_short_backtrace::h8998defd518dbcad
   9:        0x1011921b0 - _rust_begin_unwind
  10:        0x1012036a4 - core::panicking::panic_fmt::ha46aa9af97eb193d
  11:        0x10cbcbf94 - <rustc_query_system[376554ccb6bbe62f]::dep_graph::dep_node::DepNode<rustc_middle[a5107c7538e61c53]::dep_graph::dep_node::DepKind> as rustc_middle[a5107c7538e61c53]::dep_graph::dep_node::DepNodeExt>::extract_def_id::{closure#0}
  12:        0x10cba395c - <rustc_middle[a5107c7538e61c53]::ty::context::TyCtxt>::def_path_hash_to_def_id
  13:        0x10cbcbf14 - <rustc_query_system[376554ccb6bbe62f]::dep_graph::dep_node::DepNode<rustc_middle[a5107c7538e61c53]::dep_graph::dep_node::DepKind> as rustc_middle[a5107c7538e61c53]::dep_graph::dep_node::DepNodeExt>::extract_def_id
  14:        0x10c134450 - rustc_query_impl[ebd438b5e01d582b]::plumbing::force_from_dep_node::<rustc_query_impl[ebd438b5e01d582b]::queries::local_def_id_to_hir_id>
  15:        0x10cb8f518 - <rustc_middle[a5107c7538e61c53]::ty::context::TyCtxt as rustc_query_system[376554ccb6bbe62f]::dep_graph::DepContext>::try_force_from_dep_node
  16:        0x10c08c610 - <rustc_query_system[376554ccb6bbe62f]::dep_graph::graph::DepGraph<rustc_middle[a5107c7538e61c53]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[ebd438b5e01d582b]::plumbing::QueryCtxt>
  17:        0x10c08c5e0 - <rustc_query_system[376554ccb6bbe62f]::dep_graph::graph::DepGraph<rustc_middle[a5107c7538e61c53]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[ebd438b5e01d582b]::plumbing::QueryCtxt>
  18:        0x10c05cdb0 - <rustc_query_system[376554ccb6bbe62f]::dep_graph::graph::DepGraph<rustc_middle[a5107c7538e61c53]::dep_graph::dep_node::DepKind>>::try_mark_green::<rustc_query_impl[ebd438b5e01d582b]::plumbing::QueryCtxt>
  19:        0x10be17cc4 - rustc_query_system[376554ccb6bbe62f]::query::plumbing::ensure_must_run::<rustc_query_impl[ebd438b5e01d582b]::plumbing::QueryCtxt, rustc_span[b9fdb1d50c47c7fe]::def_id::LocalDefId, rustc_span[b9fdb1d50c47c7fe]::def_id::LocalDefId>
  20:        0x10bf27b98 - rustc_query_system[376554ccb6bbe62f]::query::plumbing::get_query::<rustc_query_impl[ebd438b5e01d582b]::queries::check_mod_item_types, rustc_query_impl[ebd438b5e01d582b]::plumbing::QueryCtxt>
  21:        0x10b592264 - <rustc_middle[a5107c7538e61c53]::hir::map::Map>::for_each_module::<rustc_typeck[4423ce6fa4a8f5dd]::check_crate::{closure#6}::{closure#0}>
  22:        0x10b5cd97c - <rustc_session[d9f8ead3a6f8da8f]::session::Session>::time::<(), rustc_typeck[4423ce6fa4a8f5dd]::check_crate::{closure#6}>
  23:        0x10b6c0558 - rustc_typeck[4423ce6fa4a8f5dd]::check_crate
  24:        0x1090050f0 - rustc_interface[64ac8d545596c047]::passes::analysis
  25:        0x10c0c20ec - <rustc_query_system[376554ccb6bbe62f]::dep_graph::graph::DepGraph<rustc_middle[a5107c7538e61c53]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[a5107c7538e61c53]::ty::context::TyCtxt, (), core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>
  26:        0x10bed0000 - rustc_query_system[376554ccb6bbe62f]::query::plumbing::try_execute_query::<rustc_query_impl[ebd438b5e01d582b]::plumbing::QueryCtxt, rustc_query_system[376554ccb6bbe62f]::query::caches::DefaultCache<(), core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>>
  27:        0x10bf3702c - rustc_query_system[376554ccb6bbe62f]::query::plumbing::get_query::<rustc_query_impl[ebd438b5e01d582b]::queries::analysis, rustc_query_impl[ebd438b5e01d582b]::plumbing::QueryCtxt>
  28:        0x108f27054 - <rustc_interface[64ac8d545596c047]::passes::QueryContext>::enter::<rustc_driver[250dcea03822790c]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>
  29:        0x108efc1b4 - rustc_interface[64ac8d545596c047]::interface::create_compiler_and_run::<core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>, rustc_driver[250dcea03822790c]::run_compiler::{closure#1}>
  30:        0x108f5f5e0 - <scoped_tls[1c31aea71029b747]::ScopedKey<rustc_span[b9fdb1d50c47c7fe]::SessionGlobals>>::set::<rustc_interface[64ac8d545596c047]::interface::run_compiler<core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>, rustc_driver[250dcea03822790c]::run_compiler::{closure#1}>::{closure#0}, core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>
  31:        0x108f2adc8 - std[a5ccfe66677bd8c7]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[64ac8d545596c047]::util::run_in_thread_pool_with_globals<rustc_interface[64ac8d545596c047]::interface::run_compiler<core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>, rustc_driver[250dcea03822790c]::run_compiler::{closure#1}>::{closure#0}, core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>::{closure#0}, core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>
  32:        0x108f2dc4c - <<std[a5ccfe66677bd8c7]::thread::Builder>::spawn_unchecked_<rustc_interface[64ac8d545596c047]::util::run_in_thread_pool_with_globals<rustc_interface[64ac8d545596c047]::interface::run_compiler<core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>, rustc_driver[250dcea03822790c]::run_compiler::{closure#1}>::{closure#0}, core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>::{closure#0}, core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>::{closure#1} as core[75a5a00debbb3d3d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:        0x10119a428 - std::sys::unix::thread::Thread::new::thread_start::hf682c03d0f237892
  34:        0x1a566606c - __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.65.0 (897e37553 2022-11-02) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack

```

</p>
</details>