Closed
Description
struct Foo<T> {
x: Foo<[T; 1]>,
y: T,
}
struct Bar {
x: Foo<Bar>,
}
has the following output:
error[E0072]: recursive type `Foo` has infinite size
--> src/lib.rs:1:1
|
1 | struct Foo<T> {
| ^^^^^^^^^^^^^ recursive type has infinite size
2 | x: Foo<[T; 1]>,
| ----------- recursive without indirection
|
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Foo` representable
|
2 | x: Box<Foo<[T; 1]>>,
| ^^^^ ^
thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
the stack overflow should not happen ^^