Repository: rust
Issue: GAT ICE: dtorck encountered internal error
Labels: I-ICE,T-compiler,glacier,GATs-triaged,S-has-mcve,S-bug-has-test,A-GATs

<!--
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/

-->

The issue appeared when following and using the TypeFamily pattern:
### Code

```Rust
#![feature(generic_associated_types)]


pub trait Trait1 {
    type Associated: Ord;
}

pub trait Trait2 {
    type Associated: Clone;
}

pub trait GatTrait {
    type Gat<T: Clone>;
}

pub struct GatStruct;

impl GatTrait for GatStruct {
    type Gat<T: Clone> = Box<T>;
}

pub struct OuterStruct<T1: Trait1, T2: Trait2> {
    inner: InnerStruct<T2, GatStruct>,
    t1:    T1,
}

pub struct InnerStruct<T: Trait2, G: GatTrait> {
    pub gat: G::Gat<T::Associated>,
}

impl<T1, T2> OuterStruct<T1, T2>
where
    T1: Trait1,
    T2: Trait2<Associated = T1::Associated>,
{
    pub fn new() -> Self {
        todo!()
    }
}
```

[Playground link](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=c36bcfa17130cdf660bdfd9a82747971)


### 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.59.0-nightly (efec54529 2021-12-04)
binary: rustc
commit-hash: efec545293b9263be9edfb283a7aa66350b3acbf
commit-date: 2021-12-04
host: x86_64-apple-darwin
release: 1.59.0-nightly
LLVM version: 13.0.0
```

### Error output

```
error: internal compiler error: dtorck encountered internal error
  --> src/source.rs:16:26
   |
16 |       pub fn new() -> Self {
   |  __________________________^
17 | |         todo!()
18 | |     }
   | |_____^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs:67:18

error: internal compiler error: dtorck encountered internal error
  --> src/source.rs:17:9
   |
17 |         todo!()
   |         ^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs:67:18
   = note: this error: internal compiler error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1189:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic
```

<!--
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>

```
error: internal compiler error: dtorck encountered internal error
  --> src/source.rs:16:26
   |
16 |       pub fn new() -> Self {
   |  __________________________^
17 | |         todo!()
18 | |     }
   | |_____^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs:67:18

error: internal compiler error: dtorck encountered internal error
  --> src/source.rs:17:9
   |
17 |         todo!()
   |         ^^^^^^^
   |
   = note: delayed at compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs:67:18
   = note: this error: internal compiler error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1189:13
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_display::<&str>
   3: <rustc_errors::HandlerInner>::flush_delayed
   4: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   5: core::ptr::drop_in_place::<rustc_session::parse::ParseSess>
   6: <alloc::rc::Rc<rustc_session::session::Session> as core::ops::drop::Drop>::drop
   7: core::ptr::drop_in_place::<rustc_interface::interface::Compiler>
   8: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
   9: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.59.0-nightly (efec54529 2021-12-04) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
warning: `cozal` (lib) generated 1 warning
error: could not compile `cozal`; 1 warning emitted
```

</p>
</details>