Repository: rust
Issue: Stack overflow with `clashing_extern_declarations`
Labels: I-crash,A-lints,T-compiler,C-bug

### Code

```
#![warn(clashing_extern_declarations)]

#[repr(C)]
struct A<T> {
    a: *const A<A<T>>,
    t: T,
}

#[repr(C)]
struct B<T> {
    b: *const B<B<T>>,
    t: T,
}

pub mod x {
    extern "C" {
        pub fn bar(_: super::A<i32>);
    }
}
pub mod y {
    extern "C" {
        pub fn bar(_: super::B<i32>);
        //~^ WARN `bar` redeclared with a different signature
    }
}
```

### Affected release channels

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

### Rust Version

stable and nightly

### Current error output

Not relevant

### Backtrace

```
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x32b0323)[0x7f20888aa323]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x14420)[0x7f20854a9420]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(_RNvMs3_NtNtCsfYN5AaPO7EC_12rustc_middle2ty7contextNtB5_13CtxtInterners9intern_ty+0x62)[0x7f2086a16112]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x48300d3)[0x7f2089e2a0d3]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x482ff4e)[0x7f2089e29f4e]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x483016a)[0x7f2089e2a16a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(_RNvMsL_NtCsfYN5AaPO7EC_12rustc_middle2tyNtB5_8FieldDef2ty+0x14a)[0x7f2089e285ca]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb949)[0x7f208a5d5949]

### cycle encountered after 8 frames with period 10
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
### recursed 24 times

/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdbce9)[0x7f208a5d5ce9]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-3f4ebb066deec3c0.so(+0x4fdb98a)[0x7f208a5d598a]

note: rustc unexpectedly overflowed its stack! this is a bug
```

### Anything else?

_No response_