Compiler goes out of memory


This little snippet enables an infinite recursion and after several minutes the compiler crashes with an out of memory error:

enum A {
B(A, A)

I believe this should be captured before? Sorry if that is already known, I stumbled about it today and was suprised for a moment. :slight_smile:


after trying in playpen I found this error

error: recursive type `A` has infinite size [--explain E0072]
 --> <anon>:1:1
1 |> enum A {
  |> ^
help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `A` representable


Iā€™m on Windows with Rust 1.8. I get this (with cargo run):

D:\Rust-Stuff\poly>cargo run
Compiling poly v0.1.0 (file:///D:/Rust-Stuff/poly)
fatal runtime error: out of memory
Could not compile poly.

To learn more, run the command again with --verbose.

But it took over a minute.


Looks like this is indeed a bug in the stable compiler, which is fixed in nightly:

Looks like the original issue is