Repository: rust
Issue: Overflow evaluating type occurs after adding a comment without cleaning
Labels: T-compiler,A-incr-comp,C-bug

<!--
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.
-->

Note: This sample was shared with me on twitter, and I'm replicating it here with permission

I tried this code:

```rust
type O0<T> = Option<T>;
type O1<T> = O0<O0<T>>;
type O2<T> = O1<O1<T>>;
type O3<T> = O2<O2<T>>;
type O4<T> = O3<O3<T>>;
type O5<T> = O4<O4<T>>;
type O6<T> = O5<O5<T>>;
type O7<T> = O6<O6<T>>;
type O8<T> = O7<O7<T>>;
type O9<T> = O8<O8<T>>;

type Q128<T> = O7<T>;
type Q129<T> = O7<O0<T>>;
type Q253<T> = O7<O6<O5<O4<O3<O2<O0<T>>>>>>>;
type Q254<T> = O7<O6<O5<O4<O3<O2<O1<T>>>>>>>;
type Q255<T> = O7<O6<O5<O4<O3<O2<O1<O0<T>>>>>>>>;
type Q256<T> = O8<T>;
type Q257<T> = O8<O0<T>>;
type Q384<T> = O8<O7<T>>;
type Q510<T> = O8<O7<O6<O5<O4<O3<O2<O1<T>>>>>>>>;
type Q511<T> = O8<O7<O6<O5<O4<O3<O2<O1<O0<T>>>>>>>>>;
type Q512<T> = O9<T>;
type Q513<T> = O9<O0<T>>;

enum B {
    B0,
}
enum C {
    C0,
    C1,
}
enum D {
    D0,
    D1,
    D2,
}

fn f<T>(n: u32) {
    print!("{}:{} ", n, std::mem::size_of::<T>());
}

fn describe<T>() {
    // Adding " // 1" to the end of the next line causes a build error
    f::<Q128<T>>(128);
    f::<Q129<T>>(129); // 1
    f::<Q253<T>>(253); // 1
    f::<Q254<T>>(254); // 1
    f::<Q255<T>>(255); // 1
    f::<Q256<T>>(256); // 2
    f::<Q257<T>>(257); // 2
    f::<Q384<T>>(384); // 2
    f::<Q510<T>>(510); // 2
    f::<Q511<T>>(511); // 3
                       // f::<Q512<T>>(512);
                       // f::<Q513<T>>(513);
    println!("");
}

fn main() {
    describe::<()>();
    describe::<B>();
    describe::<C>();
    describe::<D>();
}
```

I expected to see this happen: Adding the comment as indicated on line 44 built successfully

Instead, this happened: Running the code as written, adding the comment, and then running *without cleaning* causes 
```
error: overflow representing the type `C`
```

Cleaning between adding the comment and running the code causes the code to run successfully

So the error occurs if you:
1. run the code as is
2. add the comment on the indicated line
3. run the modified code

But if you clean after getting the error it builds fine, even though only a comment has changed. Increasing the recursion_limit does still make the problem go away, though I haven't experimented with which exact values resolve it yet.

### 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.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: x86_64-pc-windows-msvc
release: 1.63.0
LLVM version: 14.0.5

rustc 1.65.0-nightly (75b7e52e9 2022-08-13)
binary: rustc
commit-hash: 75b7e52e92c3b00fc891b47f5b2efdff0a2be55a
commit-date: 2022-08-13
host: x86_64-pc-windows-msvc
release: 1.65.0-nightly
LLVM version: 15.0.0
```