Repository: rust
Issue: [ICE]: Panic with recursive type + GAT
Labels: I-ICE,P-medium,T-compiler,regression-from-stable-to-stable,C-bug,S-bug-has-test,fixed-by-next-solver,A-GATs

### Code

```Rust
pub trait Functor
{
    type With<T>: Functor;
}

pub struct IdFunctor<T>(T);
impl<T> Functor for IdFunctor<T> {
    type With<T2> = IdFunctor<T2>;
}

impl<T> Functor for Vec<T> {
    type With<T2> = Vec<T2> ;
}


pub struct Compose<F1, F2, T>(F1::With<F2::With<T>>)
where
    F1: Functor + ?Sized,
    F2: Functor + ?Sized;

impl<F1, F2, T> Functor for Compose<F1, F2, T>
where
    F1: Functor + ?Sized,
    F2: Functor + ?Sized
{
    type With<T2> = F1::With<F2::With<T2>> ;
}

pub enum Value<F>
where
    F: Functor + ?Sized,
{
    SignedInt(*mut F::With<i64>),
    Array(*mut Value<Compose<F, Vec<()>, ()>>),

}

fn main() {
    let x: Value<IdFunctor<()>> = Value::SignedInt(&mut IdFunctor(1));
}
```


### Affected release channels

- [ ] Previous Stable
- [X] Current Stable
- [X] Current Beta
- [x] Current Nightly

### Rust Version

```Shell
Compiled on the playground so here is the info I could gather:

note: rustc 1.69.0-nightly (d7948c843 2023-01-26) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2
note: some of the compiler flags provided by cargo are hidden
```


### Current error output

```Shell
 
⣿
Standard Error

   Compiling playground v0.0.1 (/playground)
warning: unused variable: `x`
  --> src/main.rs:39:9
   |
39 |     let x: Value<IdFunctor<()>> = Value::SignedInt(&mut IdFunctor(1));
   |         ^ help: if this is intentional, prefix it with an underscore: `_x`
   |
   = note: `#[warn(unused_variables)]` on by default

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /cargo/registry/src/github.com-1ecc6299db9ec823/ena-0.14.0

[...]

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.69.0-nightly (d7948c843 2023-01-26) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [is_sized_raw] computing whether `_` is `Sized`
#1 [layout_of] computing layout of `*mut _`
#2 [layout_of] computing layout of `*mut <Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<IdFunctor<()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()> as Functor>::With<i64>`
#3 [layout_of] computing layout of `Value<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<Compose<IdFunctor<()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>, alloc::vec::Vec<()>, ()>>`
end of query stack
warning: `playground` (bin "playground") generated 1 warning (run `cargo fix --bin "playground"` to apply 1 suggestion)
error: could not compile `playground`; 1 warning emitted
```


### Backtrace

```Shell
Apologies for pastebin, but github rejects issues with more than 65536 char:
https://pastebin.com/jsEBz8MM
```


### Anything else?

replacing this:
```rust
    SignedInt(*mut F::With<i64>),
[...]
    let x: Value<IdFunctor<()>> = Value::SignedInt(&mut IdFunctor(1));
```

By that:
```rust
    SignedInt(F::With<i64>),
[...]
    let x: Value<IdFunctor<()>> = Value::SignedInt(IdFunctor(1));
```

brings a "normal compiler error":
```
error[[E0275]](https://doc.rust-lang.org/nightly/error-index.html#E0275): overflow evaluating the requirement `Value<Compose<Compose<Compose<Compose<Compose<Compose<..., ..., ...>, ..., ...>, ..., ...>, ..., ...>, ..., ...>, ..., ...>>: Sized`
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`playground`)
```

Which seems pretty consistent with the error encountered with the pointer:
```
#0 [is_sized_raw] computing whether `_` is `Sized`
```