Repository: rust
Issue: parallel compiler: `assertion failed: found_cycle`
Labels: I-ICE,T-compiler,C-bug,WG-compiler-parallel

<!--
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

This is on top of https://github.com/Zoxc/rust/tree/missing-cycle-test
code from a rustdoc test
```Rust
#![crate_name = "foo"]

use std::ops;

pub struct Foo;

impl Foo {
    pub fn foo(&mut self) {}
}

// @has foo/struct.Bar.html
// @has - '//*[@class="sidebar-elems"]//*[@class="block"]//a[@href="#method.foo"]' 'foo'
pub struct Bar {
    foo: Foo,
}

impl ops::Deref for Bar {
    type Target = Foo;

    fn deref(&self) -> &Foo {
        &self.foo
    }
}

impl ops::DerefMut for Bar {
    fn deref_mut(&mut self) -> &mut Foo {
        &mut self.foo
    }
}
```


### 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.
-->

Unfortunately I needed a BUNCH of tries to reproduce this

<!--
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>

```
 ~/.rustup/toolchains/local-debug-assertions/bin/rustc deref-mut-methods.rs --crate-type lib -Zthreads=10


thread '<unnamed>' panicked at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_query_system/src/query/job.rs:556:5:
assertion failed: found_cycle
stack backtrace:
   0:     0x7f18fc942521 - std::backtrace_rs::backtrace::libunwind::trace::h818fd7fcd2897c6b
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f18fc942521 - std::backtrace_rs::backtrace::trace_unsynchronized::hf2d8941579cdb3be
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f18fc942521 - std::sys_common::backtrace::_print_fmt::he4a494b921534d89
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f18fc942521 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5a3fdc94d861e4aa
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f18fc9b5107 - core::fmt::rt::Argument::fmt::h4a90583b766ae427
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/fmt/rt.rs:138:9
   5:     0x7f18fc9b5107 - core::fmt::write::h6089469c4b40ae1f
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f18fc91fc05 - std::io::Write::write_fmt::h897693c3d30f01da
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/io/mod.rs:1714:15
   7:     0x7f18fc9422f4 - std::sys_common::backtrace::_print::hb4dbec298bba652d
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f18fc9422f4 - std::sys_common::backtrace::print::h9ddc492b2d8467df
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f18fc94e52f - std::panicking::panic_hook_with_disk_dump::{{closure}}::h940f867d76beae55
  10:     0x7f18fc94e17b - std::panicking::panic_hook_with_disk_dump::h5e02febb31a69553
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:312:9
  11:     0x7f18ff6a54b0 - rustc_driver_impl[2e22a4f0ec595adf]::install_ice_hook::{closure#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_driver_impl/src/lib.rs:1335:13
  12:     0x7f18fc94ee78 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h05114cf4e5ed0f4a
                               at /home/matthias/vcs/github/rust_debug_assertions/library/alloc/src/boxed.rs:2021:9
  13:     0x7f18fc94ee78 - std::panicking::rust_panic_with_hook::h40904d4b98be6c90
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:733:13
  14:     0x7f18fc942981 - std::panicking::begin_panic_handler::{{closure}}::h0b4db4639685b376
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:619:13
  15:     0x7f18fc9427b6 - std::sys_common::backtrace::__rust_end_short_backtrace::hcbd9c82d981610ed
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:170:18
  16:     0x7f18fc94e9e2 - rust_begin_unwind
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:617:5
  17:     0x7f18fc9d8093 - core::panicking::panic_fmt::h6c5efd4701442ee1
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/panicking.rs:67:14
  18:     0x7f18fc9d8125 - core::panicking::panic::h21a5475c4c7a4bc1
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/panicking.rs:117:5
  19:     0x7f18ff671157 - rustc_query_system[ca0fea7cc8dea863]::query::job::deadlock::<rustc_middle[f8bef1f46914c7d3]::dep_graph::dep_node::DepKind>
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_query_system/src/query/job.rs:556:5
  20:     0x7f18ff68decd - rustc_interface[ce4c9a8aa2f4660b]::util::run_in_thread_pool_with_globals::<rustc_interface[ce4c9a8aa2f4660b]::interface::run_compiler<core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>, rustc_driver_impl[2e22a4f0ec595adf]::run_compiler::{closure#1}>::{closure#0}, core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>>::{closure#1}::{closure#1}
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_interface/src/util.rs:214:35
  21:     0x7f18ff68decd - std[81a1ea1164486f60]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ce4c9a8aa2f4660b]::util::run_in_thread_pool_with_globals<rustc_interface[ce4c9a8aa2f4660b]::interface::run_compiler<core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>, rustc_driver_impl[2e22a4f0ec595adf]::run_compiler::{closure#1}>::{closure#0}, core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>>::{closure#1}::{closure#1}, ()>
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:154:18
  22:     0x7f18ff65477c - <std[81a1ea1164486f60]::thread::Builder>::spawn_unchecked_::<rustc_interface[ce4c9a8aa2f4660b]::util::run_in_thread_pool_with_globals<rustc_interface[ce4c9a8aa2f4660b]::interface::run_compiler<core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>, rustc_driver_impl[2e22a4f0ec595adf]::run_compiler::{closure#1}>::{closure#0}, core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>>::{closure#1}::{closure#1}, ()>::{closure#1}::{closure#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/thread/mod.rs:529:17
  23:     0x7f18ff65477c - <core[eb9f5097525910b2]::panic::unwind_safe::AssertUnwindSafe<<std[81a1ea1164486f60]::thread::Builder>::spawn_unchecked_<rustc_interface[ce4c9a8aa2f4660b]::util::run_in_thread_pool_with_globals<rustc_interface[ce4c9a8aa2f4660b]::interface::run_compiler<core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>, rustc_driver_impl[2e22a4f0ec595adf]::run_compiler::{closure#1}>::{closure#0}, core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>>::{closure#1}::{closure#1}, ()>::{closure#1}::{closure#0}> as core[eb9f5097525910b2]::ops::function::FnOnce<()>>::call_once
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/panic/unwind_safe.rs:271:9
  24:     0x7f18ff65477c - std[81a1ea1164486f60]::panicking::try::do_call::<core[eb9f5097525910b2]::panic::unwind_safe::AssertUnwindSafe<<std[81a1ea1164486f60]::thread::Builder>::spawn_unchecked_<rustc_interface[ce4c9a8aa2f4660b]::util::run_in_thread_pool_with_globals<rustc_interface[ce4c9a8aa2f4660b]::interface::run_compiler<core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>, rustc_driver_impl[2e22a4f0ec595adf]::run_compiler::{closure#1}>::{closure#0}, core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>>::{closure#1}::{closure#1}, ()>::{closure#1}::{closure#0}>, ()>
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:524:40
  25:     0x7f18ff65477c - std[81a1ea1164486f60]::panicking::try::<(), core[eb9f5097525910b2]::panic::unwind_safe::AssertUnwindSafe<<std[81a1ea1164486f60]::thread::Builder>::spawn_unchecked_<rustc_interface[ce4c9a8aa2f4660b]::util::run_in_thread_pool_with_globals<rustc_interface[ce4c9a8aa2f4660b]::interface::run_compiler<core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>, rustc_driver_impl[2e22a4f0ec595adf]::run_compiler::{closure#1}>::{closure#0}, core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>>::{closure#1}::{closure#1}, ()>::{closure#1}::{closure#0}>>
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:488:19
  26:     0x7f18ff65477c - std[81a1ea1164486f60]::panic::catch_unwind::<core[eb9f5097525910b2]::panic::unwind_safe::AssertUnwindSafe<<std[81a1ea1164486f60]::thread::Builder>::spawn_unchecked_<rustc_interface[ce4c9a8aa2f4660b]::util::run_in_thread_pool_with_globals<rustc_interface[ce4c9a8aa2f4660b]::interface::run_compiler<core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>, rustc_driver_impl[2e22a4f0ec595adf]::run_compiler::{closure#1}>::{closure#0}, core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>>::{closure#1}::{closure#1}, ()>::{closure#1}::{closure#0}>, ()>
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panic.rs:142:14
  27:     0x7f18ff65477c - <std[81a1ea1164486f60]::thread::Builder>::spawn_unchecked_::<rustc_interface[ce4c9a8aa2f4660b]::util::run_in_thread_pool_with_globals<rustc_interface[ce4c9a8aa2f4660b]::interface::run_compiler<core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>, rustc_driver_impl[2e22a4f0ec595adf]::run_compiler::{closure#1}>::{closure#0}, core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>>::{closure#1}::{closure#1}, ()>::{closure#1}
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/thread/mod.rs:528:30
  28:     0x7f18ff65477c - <<std[81a1ea1164486f60]::thread::Builder>::spawn_unchecked_<rustc_interface[ce4c9a8aa2f4660b]::util::run_in_thread_pool_with_globals<rustc_interface[ce4c9a8aa2f4660b]::interface::run_compiler<core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>, rustc_driver_impl[2e22a4f0ec595adf]::run_compiler::{closure#1}>::{closure#0}, core[eb9f5097525910b2]::result::Result<(), rustc_span[5060e7939b3129d]::ErrorGuaranteed>>::{closure#1}::{closure#1}, ()>::{closure#1} as core[eb9f5097525910b2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/ops/function.rs:250:5
  29:     0x7f18fc940439 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h197d07c7abf2c25e
                               at /home/matthias/vcs/github/rust_debug_assertions/library/alloc/src/boxed.rs:2007:9
  30:     0x7f18fc940439 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hcb59e37a449b5256
                               at /home/matthias/vcs/github/rust_debug_assertions/library/alloc/src/boxed.rs:2007:9
  31:     0x7f18fc94f895 - std::sys::unix::thread::Thread::new::thread_start::h699f0086e43bdec6
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys/unix/thread.rs:108:17
  32:     0x7f18fc48c9eb - <unknown>
  33:     0x7f18fc510ebc - <unknown>
  34:                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: please attach the file at `/tmp/par/rustc-ice-2023-08-25T19:33:47.445875318Z-4142659.txt` to your bug report

note: compiler flags: --crate-type lib -Z threads=10

query stack during panic:
end of query stack
deadlock handler panicked, aborting process

[1]    4142659 IOT instruction  ~/.rustup/toolchains/local-debug-assertions/bin/rustc deref-mut-methods.rs
```

</p>
</details>