diff --git a/src/test/ui/issues/issue-74224.rs b/src/test/ui/issues/issue-74224.rs new file mode 100644 index 00000000000..f3b72c5df7f --- /dev/null +++ b/src/test/ui/issues/issue-74224.rs @@ -0,0 +1,11 @@ +struct A { +//~^ ERROR recursive type `A` has infinite size + x: T, + y: A>, +} + +struct B { + z: A +} + +fn main() {} diff --git a/src/test/ui/issues/issue-74224.stderr b/src/test/ui/issues/issue-74224.stderr new file mode 100644 index 00000000000..d61ab1952f9 --- /dev/null +++ b/src/test/ui/issues/issue-74224.stderr @@ -0,0 +1,17 @@ +error[E0072]: recursive type `A` has infinite size + --> $DIR/issue-74224.rs:1:1 + | +LL | struct A { + | ^^^^^^^^^^^ recursive type has infinite size +... +LL | y: A>, + | ------- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `A` representable + | +LL | y: Box>>, + | ^^^^ ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0072`. diff --git a/src/test/ui/issues/issue-84611.rs b/src/test/ui/issues/issue-84611.rs new file mode 100644 index 00000000000..4c356af3eb8 --- /dev/null +++ b/src/test/ui/issues/issue-84611.rs @@ -0,0 +1,11 @@ +struct Foo { +//~^ ERROR recursive type `Foo` has infinite size + x: Foo<[T; 1]>, + y: T, +} + +struct Bar { + x: Foo, +} + +fn main() {} diff --git a/src/test/ui/issues/issue-84611.stderr b/src/test/ui/issues/issue-84611.stderr new file mode 100644 index 00000000000..0a898e5c46d --- /dev/null +++ b/src/test/ui/issues/issue-84611.stderr @@ -0,0 +1,17 @@ +error[E0072]: recursive type `Foo` has infinite size + --> $DIR/issue-84611.rs:1:1 + | +LL | struct Foo { + | ^^^^^^^^^^^^^ recursive type has infinite size +LL | +LL | x: Foo<[T; 1]>, + | ----------- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Foo` representable + | +LL | x: Box>, + | ^^^^ ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0072`. diff --git a/src/test/ui/mutual-struct-recursion.rs b/src/test/ui/mutual-struct-recursion.rs new file mode 100644 index 00000000000..cca97f43eff --- /dev/null +++ b/src/test/ui/mutual-struct-recursion.rs @@ -0,0 +1,23 @@ +struct A { +//~^ ERROR recursive type `A` has infinite size + x: T, + y: B, +} + +struct B { +//~^ ERROR recursive type `B` has infinite size + z: A +} + +struct C { +//~^ ERROR recursive type `C` has infinite size + x: T, + y: Option>>, +} + +struct D { +//~^ ERROR recursive type `D` has infinite size + z: Option>>, +} + +fn main() {} diff --git a/src/test/ui/mutual-struct-recursion.stderr b/src/test/ui/mutual-struct-recursion.stderr new file mode 100644 index 00000000000..efc4ba93f0a --- /dev/null +++ b/src/test/ui/mutual-struct-recursion.stderr @@ -0,0 +1,59 @@ +error[E0072]: recursive type `A` has infinite size + --> $DIR/mutual-struct-recursion.rs:1:1 + | +LL | struct A { + | ^^^^^^^^^^^ recursive type has infinite size +... +LL | y: B, + | ---- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `A` representable + | +LL | y: Box>, + | ^^^^ ^ + +error[E0072]: recursive type `B` has infinite size + --> $DIR/mutual-struct-recursion.rs:7:1 + | +LL | struct B { + | ^^^^^^^^^^^ recursive type has infinite size +LL | +LL | z: A + | ---- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `B` representable + | +LL | z: Box> + | ^^^^ ^ + +error[E0072]: recursive type `C` has infinite size + --> $DIR/mutual-struct-recursion.rs:12:1 + | +LL | struct C { + | ^^^^^^^^^^^ recursive type has infinite size +... +LL | y: Option>>, + | -------------------- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `C` representable + | +LL | y: Box>>>, + | ^^^^ ^ + +error[E0072]: recursive type `D` has infinite size + --> $DIR/mutual-struct-recursion.rs:18:1 + | +LL | struct D { + | ^^^^^^^^^^^ recursive type has infinite size +LL | +LL | z: Option>>, + | -------------------- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `D` representable + | +LL | z: Box>>>, + | ^^^^ ^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0072`.