summaryrefslogtreecommitdiffstats
path: root/tests/ui/structs-enums
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /tests/ui/structs-enums
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/structs-enums')
-rw-r--r--tests/ui/structs-enums/issue-3008-1.rs12
-rw-r--r--tests/ui/structs-enums/issue-3008-1.stderr17
-rw-r--r--tests/ui/structs-enums/issue-3008-2.rs6
-rw-r--r--tests/ui/structs-enums/issue-3008-2.stderr14
-rw-r--r--tests/ui/structs-enums/issue-3008-3.rs10
-rw-r--r--tests/ui/structs-enums/issue-3008-3.stderr14
6 files changed, 73 insertions, 0 deletions
diff --git a/tests/ui/structs-enums/issue-3008-1.rs b/tests/ui/structs-enums/issue-3008-1.rs
new file mode 100644
index 000000000..1124969e6
--- /dev/null
+++ b/tests/ui/structs-enums/issue-3008-1.rs
@@ -0,0 +1,12 @@
+enum Foo {
+ Foo_(Bar)
+}
+
+enum Bar {
+ //~^ ERROR recursive type `Bar` has infinite size
+ BarNone,
+ BarSome(Bar)
+}
+
+fn main() {
+}
diff --git a/tests/ui/structs-enums/issue-3008-1.stderr b/tests/ui/structs-enums/issue-3008-1.stderr
new file mode 100644
index 000000000..be25b9091
--- /dev/null
+++ b/tests/ui/structs-enums/issue-3008-1.stderr
@@ -0,0 +1,17 @@
+error[E0072]: recursive type `Bar` has infinite size
+ --> $DIR/issue-3008-1.rs:5:1
+ |
+LL | enum Bar {
+ | ^^^^^^^^
+...
+LL | BarSome(Bar)
+ | --- recursive without indirection
+ |
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
+ |
+LL | BarSome(Box<Bar>)
+ | ++++ +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0072`.
diff --git a/tests/ui/structs-enums/issue-3008-2.rs b/tests/ui/structs-enums/issue-3008-2.rs
new file mode 100644
index 000000000..5846c69da
--- /dev/null
+++ b/tests/ui/structs-enums/issue-3008-2.rs
@@ -0,0 +1,6 @@
+enum Foo { Foo_(Bar) }
+struct Bar { x: Bar }
+//~^ ERROR E0072
+
+fn main() {
+}
diff --git a/tests/ui/structs-enums/issue-3008-2.stderr b/tests/ui/structs-enums/issue-3008-2.stderr
new file mode 100644
index 000000000..858a8fd6a
--- /dev/null
+++ b/tests/ui/structs-enums/issue-3008-2.stderr
@@ -0,0 +1,14 @@
+error[E0072]: recursive type `Bar` has infinite size
+ --> $DIR/issue-3008-2.rs:2:1
+ |
+LL | struct Bar { x: Bar }
+ | ^^^^^^^^^^ --- recursive without indirection
+ |
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
+ |
+LL | struct Bar { x: Box<Bar> }
+ | ++++ +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0072`.
diff --git a/tests/ui/structs-enums/issue-3008-3.rs b/tests/ui/structs-enums/issue-3008-3.rs
new file mode 100644
index 000000000..212eb2eb8
--- /dev/null
+++ b/tests/ui/structs-enums/issue-3008-3.rs
@@ -0,0 +1,10 @@
+use std::marker;
+
+enum E1 { V1(E2<E1>), }
+enum E2<T> { V2(E2<E1>, marker::PhantomData<T>), }
+//~^ ERROR recursive type `E2` has infinite size
+
+impl E1 { fn foo(&self) {} }
+
+fn main() {
+}
diff --git a/tests/ui/structs-enums/issue-3008-3.stderr b/tests/ui/structs-enums/issue-3008-3.stderr
new file mode 100644
index 000000000..a1a81e293
--- /dev/null
+++ b/tests/ui/structs-enums/issue-3008-3.stderr
@@ -0,0 +1,14 @@
+error[E0072]: recursive type `E2` has infinite size
+ --> $DIR/issue-3008-3.rs:4:1
+ |
+LL | enum E2<T> { V2(E2<E1>, marker::PhantomData<T>), }
+ | ^^^^^^^^^^ ------ recursive without indirection
+ |
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
+ |
+LL | enum E2<T> { V2(Box<E2<E1>>, marker::PhantomData<T>), }
+ | ++++ +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0072`.