Closed as duplicate of#132673
Closed as duplicate of#132673
Description
Running the following code with rustc leads to an infinite loop, presumably because the type checker tries to unify the type of x
(let's call it ?a
) with (?a, ?a)
fn same_type<A>(x : A, y : A) -> A {
x
}
fn main() {
let x = panic!();
let _ = same_type(x, (x,x));
}
It also fills the source directory with megabytes of increasingly massive files containing the types it is trying to unify, for example (this is one of the smaller ones):
(((((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _)))), ((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _))))), (((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _)))), ((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _)))))), ((((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _)))), ((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _))))), (((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _)))), ((((_, _), (_, _)), ((_, _), (_, _))), (((_, _), (_, _)), ((_, _), (_, _)))))))
I would have expected rustc to catch this with an occurs check and produce an error message instead.
Meta
rustc --version --verbose
:
rustc 1.85.0-nightly (14ee63a3c 2024-12-29)
binary: rustc
commit-hash: 14ee63a3c651bb7a243c8b07333749ab4b152e13
commit-date: 2024-12-29
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6