Repository: rust
Issue: rustdoc: stack overflow: rustc_infer::infer::combine::Generalizer
Labels: I-crash,T-rustdoc,T-compiler,C-bug,glacier

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->

I tried this code from `tests/ui/dropck/dropck_no_diverge_on_nonregular_2.rs`

```rust
// Issue 22443: Reject code using non-regular types that would
// otherwise cause dropck to loop infinitely.

use std::marker::PhantomData;

struct Digit<T> {
    elem: T
}

struct Node<T:'static> { m: PhantomData<&'static T> }


enum FingerTree<T:'static> {
    Single(T),
    // Bug report said Digit after Box would stack overflow (versus
    // Digit before Box; see dropck_no_diverge_on_nonregular_2).
    Deep(
        Box<FingerTree<Node<T>>>,
        Digit<T>,
        )
}

fn main() {
    let ft = //~ ERROR overflow while adding drop-check rules for FingerTree
        FingerTree::Single(1);
    //~^ ERROR overflow while adding drop-check rules for FingerTree
}
```


Instead, this happened: *explanation*

````
thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
[1]    4101068 IOT instruction (core dumped)  ~/.rustup/toolchains/master/bin/rustdoc
````

### 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.
-->

`rustdoc --version --verbose`:
```
rustdoc 1.63.0-nightly (d40f24e95 2022-06-16)
binary: rustdoc
commit-hash: d40f24e956a698e47a209541031c4045acc5a684
commit-date: 2022-06-16
host: x86_64-unknown-linux-gnu
release: 1.63.0-nightly
LLVM version: 14.0.5
```
The recursion seems to happem somewhere here:

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary>Backtrace</summary>
<p>

```
#85 0x00007ffff5e77f64 in rustc_middle::ty::relate::super_relate_tys::<rustc_infer::infer::combine::Generalizer> () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#86 0x00007ffff5ea1300 in <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::tys () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#87 0x00007ffff5e77f64 in rustc_middle::ty::relate::super_relate_tys::<rustc_infer::infer::combine::Generalizer> () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#88 0x00007ffff5ea1300 in <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::tys () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#89 0x00007ffff5e77f64 in rustc_middle::ty::relate::super_relate_tys::<rustc_infer::infer::combine::Generalizer> () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#90 0x00007ffff5ea1300 in <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::tys () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#91 0x00007ffff5e77f64 in rustc_middle::ty::relate::super_relate_tys::<rustc_infer::infer::combine::Generalizer> () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#92 0x00007ffff5ea1300 in <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::tys () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#93 0x00007ffff5e77f64 in rustc_middle::ty::relate::super_relate_tys::<rustc_infer::infer::combine::Generalizer> () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#94 0x00007ffff5ea1300 in <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::tys () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#95 0x00007ffff5e77f64 in rustc_middle::ty::relate::super_relate_tys::<rustc_infer::infer::combine::Generalizer> () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#96 0x00007ffff5ea1300 in <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::tys () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#97 0x00007ffff5e77f64 in rustc_middle::ty::relate::super_relate_tys::<rustc_infer::infer::combine::Generalizer> () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#98 0x00007ffff5ea1300 in <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::tys () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#99 0x00007ffff5e77f64 in rustc_middle::ty::relate::super_relate_tys::<rustc_infer::infer::combine::Generalizer> () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#100 0x00007ffff5ea1300 in <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::tys () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#101 0x00007ffff5e77f64 in rustc_middle::ty::relate::super_relate_tys::<rustc_infer::infer::combine::Generalizer> () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#102 0x00007ffff5ea1300 in <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::tys () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#103 0x00007ffff5e77f64 in rustc_middle::ty::relate::super_relate_tys::<rustc_infer::infer::combine::Generalizer> () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#104 0x00007ffff5ea1300 in <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::tys () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
#105 0x00007ffff5e77f64 in rustc_middle::ty::relate::super_relate_tys::<rustc_infer::infer::combine::Generalizer> () from /home/matthias/.rustup/toolchains/master/bin/../lib/librustc_driver-e1f5a2a7d671876e.so
```

</p>
</details>