Repository: rust
Issue: thread 'rustc' panicked [...] attempted to read from stolen value: rustc_query_system::dep_graph::serialized::GraphEncoder<rustc_middle::dep_graph::DepsType>
Labels: I-ICE,T-compiler,A-incr-comp,C-bug

I'm not sure how helpful this report will be, since I cannot share most of my code other than `main.rs`, which was mostly empty, since I had just started on the application and had only worked on some modules.

How it happened:
1. I ran `cargo run` and noticed the 'Hello world' wasn't printed (at this point the `target` directory already existed from earlier)
2. I added the `dbg!("h");` to see what would happen
3. Upon running `cargo run` again the compiler panicked
4. After removing the `target` directory and trying again it worked fine (I do have a backup of the directory if that's useful?)

### Code

```Rust
pub mod graph;
pub mod relations;
pub mod types;

fn main() {
    dbg!("h");   // added in step 2
    println!("Hello, world!");
}
```

### Meta

`rustc --version --verbose`:
```
rustc 1.74.1 (a28077b28 2023-12-04)
binary: rustc
commit-hash: a28077b28a02b92985b3a3faecf92813155f1ea1
commit-date: 2023-12-04
host: x86_64-unknown-linux-gnu
release: 1.74.1
LLVM version: 17.0.4
```

`lsb_release -a && uname -r`:
```
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal
5.15.133.1-microsoft-standard-WSL2
```

### Error output

<details><summary><strong>Backtrace</strong></summary>
<p>

```
thread 'rustc' panicked at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/compiler/rustc_query_system/src/dep_graph/graph.rs:1203:34:
attempted to read from stolen value: rustc_query_system::dep_graph::serialized::GraphEncoder<rustc_middle::dep_graph::DepsType>
stack backtrace:
   0:     0x7f9af888833c - std::backtrace_rs::backtrace::libunwind::trace::ha69d38c49f1bf263
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f9af888833c - std::backtrace_rs::backtrace::trace_unsynchronized::h93125d0b85fd543c
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f9af888833c - std::sys_common::backtrace::_print_fmt::h8d65f438e8343444
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f9af888833c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h41751d2af6c8033a
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f9af88edf9c - core::fmt::rt::Argument::fmt::h5db2f552d8a28f63
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/fmt/rt.rs:138:9
   5:     0x7f9af88edf9c - core::fmt::write::h99465148a27e4883
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/fmt/mod.rs:1114:21
   6:     0x7f9af887b0be - std::io::Write::write_fmt::hee8dfd57bd179ab2
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/io/mod.rs:1763:15
   7:     0x7f9af8888124 - std::sys_common::backtrace::_print::h019a3cee3e814da4
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f9af8888124 - std::sys_common::backtrace::print::h55694121c2ddf918
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f9af888b003 - std::panicking::default_hook::{{closure}}::h29cbe3da3891b0b0
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:272:22
  10:     0x7f9af888ad24 - std::panicking::default_hook::h881e76b2b8c74280
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:292:9
  11:     0x7f9afba3515f - std[afc0969a1e8d0069]::panicking::update_hook::<alloc[8b5739118bbd196f]::boxed::Box<rustc_driver_impl[edf179010582d687]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f9af888b831 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hdafd71b4fdf5de15
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/alloc/src/boxed.rs:2021:9
  13:     0x7f9af888b831 - std::panicking::rust_panic_with_hook::hcc36e25b6e33969c
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:735:13
  14:     0x7f9af888b5b1 - std::panicking::begin_panic_handler::{{closure}}::ha415efb0f69f41f9
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:609:13
  15:     0x7f9af8888866 - std::sys_common::backtrace::__rust_end_short_backtrace::h395fe90f99451e4e
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:170:18
  16:     0x7f9af888b302 - rust_begin_unwind
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
  17:     0x7f9af88ea625 - core::panicking::panic_fmt::h452a83e54ecd764e
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
  18:     0x7f9afa9586f8 - <rustc_query_system[38ffe91b6b23055d]::dep_graph::graph::DepGraph<rustc_middle[9d619393e8ff4f31]::dep_graph::DepsType>>::with_anon_task::<rustc_middle[9d619393e8ff4f31]::ty::context::TyCtxt, <rustc_trait_selection[ed3448221a2282d1]::traits::select::SelectionContext>::in_task<<rustc_trait_selection[ed3448221a2282d1]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively::{closure#0}::{closure#1}, core[e044522c7ef2d325]::result::Result<rustc_middle[9d619393e8ff4f31]::traits::select::EvaluationResult, rustc_middle[9d619393e8ff4f31]::traits::select::OverflowError>>::{closure#0}, core[e044522c7ef2d325]::result::Result<rustc_middle[9d619393e8ff4f31]::traits::select::EvaluationResult, rustc_middle[9d619393e8ff4f31]::traits::select::OverflowError>>
  19:     0x7f9afa951e58 - <rustc_trait_selection[ed3448221a2282d1]::traits::select::SelectionContext>::evaluate_predicate_recursively
  20:     0x7f9afa94eca2 - rustc_traits[3ef5fd84f22ebd6b]::evaluate_obligation::evaluate_obligation
  21:     0x7f9af9b2b4ff - rustc_query_impl[2832811689f625f6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2832811689f625f6]::query_impl::evaluate_obligation::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9d619393e8ff4f31]::query::erase::Erased<[u8; 2usize]>>
  22:     0x7f9af9b2b4c1 - <rustc_query_impl[2832811689f625f6]::query_impl::evaluate_obligation::dynamic_query::{closure#2} as core[e044522c7ef2d325]::ops::function::FnOnce<(rustc_middle[9d619393e8ff4f31]::ty::context::TyCtxt, rustc_middle[9d619393e8ff4f31]::infer::canonical::Canonical<rustc_middle[9d619393e8ff4f31]::ty::ParamEnvAnd<rustc_middle[9d619393e8ff4f31]::ty::Predicate>>)>>::call_once
  23:     0x7f9afab2c62b - rustc_query_system[38ffe91b6b23055d]::query::plumbing::try_execute_query::<rustc_query_impl[2832811689f625f6]::DynamicConfig<rustc_query_system[38ffe91b6b23055d]::query::caches::DefaultCache<rustc_middle[9d619393e8ff4f31]::infer::canonical::Canonical<rustc_middle[9d619393e8ff4f31]::ty::ParamEnvAnd<rustc_middle[9d619393e8ff4f31]::ty::Predicate>>, rustc_middle[9d619393e8ff4f31]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[2832811689f625f6]::plumbing::QueryCtxt, true>
  24:     0x7f9afab2b07c - rustc_query_impl[2832811689f625f6]::query_impl::evaluate_obligation::get_query_incr::__rust_end_short_backtrace
  25:     0x7f9af9d7a636 - <rustc_trait_selection[ed3448221a2282d1]::traits::fulfill::FulfillProcessor as rustc_data_structures[96d7b101533d65de]::obligation_forest::ObligationProcessor>::process_obligation
  26:     0x7f9af9d74ed4 - <rustc_data_structures[96d7b101533d65de]::obligation_forest::ObligationForest<rustc_trait_selection[ed3448221a2282d1]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[ed3448221a2282d1]::traits::fulfill::FulfillProcessor>
  27:     0x7f9afa653bfd - <rustc_infer[66eed79c2d45c887]::infer::InferCtxt>::make_canonicalized_query_response::<()>
  28:     0x7f9afa239c32 - <rustc_infer[66eed79c2d45c887]::infer::InferCtxtBuilder as rustc_trait_selection[ed3448221a2282d1]::infer::InferCtxtBuilderExt>::enter_canonical_trait_query::<rustc_middle[9d619393e8ff4f31]::ty::ParamEnvAnd<rustc_middle[9d619393e8ff4f31]::traits::query::type_op::ProvePredicate>, (), rustc_traits[3ef5fd84f22ebd6b]::type_op::type_op_prove_predicate::{closure#0}>
  29:     0x7f9af9b2f5b3 - rustc_query_impl[2832811689f625f6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2832811689f625f6]::query_impl::type_op_prove_predicate::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9d619393e8ff4f31]::query::erase::Erased<[u8; 8usize]>>
  30:     0x7f9af9b2f541 - <rustc_query_impl[2832811689f625f6]::query_impl::type_op_prove_predicate::dynamic_query::{closure#2} as core[e044522c7ef2d325]::ops::function::FnOnce<(rustc_middle[9d619393e8ff4f31]::ty::context::TyCtxt, rustc_middle[9d619393e8ff4f31]::infer::canonical::Canonical<rustc_middle[9d619393e8ff4f31]::ty::ParamEnvAnd<rustc_middle[9d619393e8ff4f31]::traits::query::type_op::ProvePredicate>>)>>::call_once
  31:     0x7f9afacac1c7 - rustc_query_system[38ffe91b6b23055d]::query::plumbing::try_execute_query::<rustc_query_impl[2832811689f625f6]::DynamicConfig<rustc_query_system[38ffe91b6b23055d]::query::caches::DefaultCache<rustc_middle[9d619393e8ff4f31]::infer::canonical::Canonical<rustc_middle[9d619393e8ff4f31]::ty::ParamEnvAnd<rustc_middle[9d619393e8ff4f31]::traits::query::type_op::ProvePredicate>>, rustc_middle[9d619393e8ff4f31]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2832811689f625f6]::plumbing::QueryCtxt, true>
  32:     0x7f9afacab2df - rustc_query_impl[2832811689f625f6]::query_impl::type_op_prove_predicate::get_query_incr::__rust_end_short_backtrace
  33:     0x7f9afac583e5 - <rustc_middle[9d619393e8ff4f31]::ty::ParamEnvAnd<rustc_middle[9d619393e8ff4f31]::traits::query::type_op::ProvePredicate> as rustc_trait_selection[ed3448221a2282d1]::traits::query::type_op::TypeOp>::fully_perform
  34:     0x7f9afa3c6c67 - <rustc_borrowck[16818dd8c444f33f]::type_check::TypeChecker>::normalize_and_prove_instantiated_predicates
  35:     0x7f9afa3ca77a - <rustc_borrowck[16818dd8c444f33f]::type_check::TypeVerifier as rustc_middle[9d619393e8ff4f31]::mir::visit::Visitor>::visit_constant
  36:     0x7f9afa3b305a - <rustc_borrowck[16818dd8c444f33f]::type_check::TypeVerifier as rustc_middle[9d619393e8ff4f31]::mir::visit::Visitor>::visit_body
  37:     0x7f9afa326ac3 - rustc_borrowck[16818dd8c444f33f]::type_check::type_check
  38:     0x7f9afa31a76d - rustc_borrowck[16818dd8c444f33f]::nll::compute_regions
  39:     0x7f9afa2ffacc - rustc_borrowck[16818dd8c444f33f]::do_mir_borrowck
  40:     0x7f9afa2fde93 - rustc_borrowck[16818dd8c444f33f]::mir_borrowck
  41:     0x7f9af9b93cae - rustc_query_impl[2832811689f625f6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2832811689f625f6]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9d619393e8ff4f31]::query::erase::Erased<[u8; 8usize]>>
  42:     0x7f9af9b93c7e - <rustc_query_impl[2832811689f625f6]::query_impl::mir_borrowck::dynamic_query::{closure#2} as core[e044522c7ef2d325]::ops::function::FnOnce<(rustc_middle[9d619393e8ff4f31]::ty::context::TyCtxt, rustc_span[16fed22730bc75c0]::def_id::LocalDefId)>>::call_once
  43:     0x7f9afa1e4397 - rustc_query_system[38ffe91b6b23055d]::query::plumbing::try_execute_query::<rustc_query_impl[2832811689f625f6]::DynamicConfig<rustc_query_system[38ffe91b6b23055d]::query::caches::VecCache<rustc_span[16fed22730bc75c0]::def_id::LocalDefId, rustc_middle[9d619393e8ff4f31]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2832811689f625f6]::plumbing::QueryCtxt, true>
  44:     0x7f9afb38a3f8 - rustc_query_impl[2832811689f625f6]::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
  45:     0x7f9afb3b576f - <rustc_query_impl[2832811689f625f6]::query_impl::mir_borrowck::dynamic_query::{closure#1} as core[e044522c7ef2d325]::ops::function::FnOnce<(rustc_middle[9d619393e8ff4f31]::ty::context::TyCtxt, rustc_span[16fed22730bc75c0]::def_id::LocalDefId)>>::call_once
  46:     0x7f9afb365d4a - <rustc_query_impl[2832811689f625f6]::plumbing::query_callback<rustc_query_impl[2832811689f625f6]::query_impl::mir_borrowck::QueryType>::{closure#1} as core[e044522c7ef2d325]::ops::function::FnOnce<(rustc_middle[9d619393e8ff4f31]::ty::context::TyCtxt, rustc_query_system[38ffe91b6b23055d]::dep_graph::dep_node::DepNode)>>::call_once
  47:     0x7f9afaed1a06 - <rustc_query_system[38ffe91b6b23055d]::dep_graph::graph::DepGraph<rustc_middle[9d619393e8ff4f31]::dep_graph::DepsType>>::exec_cache_promotions::<rustc_middle[9d619393e8ff4f31]::ty::context::TyCtxt>
  48:     0x7f9afaed1588 - <rustc_middle[9d619393e8ff4f31]::query::on_disk_cache::OnDiskCache>::drop_serialized_data
  49:     0x7f9afaed1462 - <rustc_session[c6557f37e70f1e4]::session::Session>::time::<(), rustc_incremental[dd1ee73bff74c743]::persist::save::save_dep_graph::{closure#0}::{closure#3}::{closure#0}>
  50:     0x7f9afaed120f - rustc_data_structures[96d7b101533d65de]::sync::parallel::disabled::join::<rustc_incremental[dd1ee73bff74c743]::persist::save::save_dep_graph::{closure#0}::{closure#2}, rustc_incremental[dd1ee73bff74c743]::persist::save::save_dep_graph::{closure#0}::{closure#3}, (), ()>
  51:     0x7f9afaed076e - rustc_incremental[dd1ee73bff74c743]::persist::save::save_dep_graph
  52:     0x7f9afaf728e3 - <rustc_session[c6557f37e70f1e4]::session::Session>::time::<(), <rustc_interface[250c7deb490bcc66]::interface::Compiler>::enter<rustc_driver_impl[edf179010582d687]::run_compiler::{closure#1}::{closure#2}, core[e044522c7ef2d325]::result::Result<core[e044522c7ef2d325]::option::Option<rustc_interface[250c7deb490bcc66]::queries::Linker>, rustc_span[16fed22730bc75c0]::ErrorGuaranteed>>::{closure#0}>
  53:     0x7f9afaf70686 - rustc_span[16fed22730bc75c0]::set_source_map::<core[e044522c7ef2d325]::result::Result<(), rustc_span[16fed22730bc75c0]::ErrorGuaranteed>, rustc_interface[250c7deb490bcc66]::interface::run_compiler<core[e044522c7ef2d325]::result::Result<(), rustc_span[16fed22730bc75c0]::ErrorGuaranteed>, rustc_driver_impl[edf179010582d687]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  54:     0x7f9afaf6a750 - std[afc0969a1e8d0069]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[250c7deb490bcc66]::util::run_in_thread_with_globals<rustc_interface[250c7deb490bcc66]::interface::run_compiler<core[e044522c7ef2d325]::result::Result<(), rustc_span[16fed22730bc75c0]::ErrorGuaranteed>, rustc_driver_impl[edf179010582d687]::run_compiler::{closure#1}>::{closure#0}, core[e044522c7ef2d325]::result::Result<(), rustc_span[16fed22730bc75c0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e044522c7ef2d325]::result::Result<(), rustc_span[16fed22730bc75c0]::ErrorGuaranteed>>
  55:     0x7f9afaf6a05e - <<std[afc0969a1e8d0069]::thread::Builder>::spawn_unchecked_<rustc_interface[250c7deb490bcc66]::util::run_in_thread_with_globals<rustc_interface[250c7deb490bcc66]::interface::run_compiler<core[e044522c7ef2d325]::result::Result<(), rustc_span[16fed22730bc75c0]::ErrorGuaranteed>, rustc_driver_impl[edf179010582d687]::run_compiler::{closure#1}>::{closure#0}, core[e044522c7ef2d325]::result::Result<(), rustc_span[16fed22730bc75c0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e044522c7ef2d325]::result::Result<(), rustc_span[16fed22730bc75c0]::ErrorGuaranteed>>::{closure#1} as core[e044522c7ef2d325]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  56:     0x7f9af8896395 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h51435299acd7166e
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/alloc/src/boxed.rs:2007:9
  57:     0x7f9af8896395 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3f833c0a4926bdd4
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/alloc/src/boxed.rs:2007:9
  58:     0x7f9af8896395 - std::sys::unix::thread::Thread::new::thread_start::h2c486d0230ab0d99
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys/unix/thread.rs:108:17
  59:     0x7f9af8750609 - start_thread
  60:     0x7f9af8673353 - clone
  61:                0x0 - <unknown>

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.74.1 (a28077b28 2023-12-04) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
thread panicked while processing panic. aborting.
error: could not compile `core2` (bin "core2")

Caused by:
  process didn't exit successfully: `/home/jefta/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name core2 --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=125 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=357ef2aba6683bb6 -C extra-filename=-357ef2aba6683bb6 --out-dir /home/jefta/Projects/core2/target/debug/deps -C incremental=/home/jefta/Projects/core2/target/debug/incremental -L dependency=/home/jefta/Projects/core2/target/debug/deps --extern hifitime=/home/jefta/Projects/core2/target/debug/deps/libhifitime-4283394d50d25a01.rlib --extern rand=/home/jefta/Projects/core2/target/debug/deps/librand-0343ea90b46d0f8b.rlib --extern slotmap=/home/jefta/Projects/core2/target/debug/deps/libslotmap-a5cda34bf35ca18e.rlib --extern thiserror=/home/jefta/Projects/core2/target/debug/deps/libthiserror-202b90ec477c8fd1.rlib` (signal: 6, SIGABRT: process abort signal)
```

</p>
</details>