summaryrefslogtreecommitdiffstats
path: root/tests/ui/structs-enums
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
commita0b8f38ab54ac451646aa00cd5e91b6c76f22a84 (patch)
treefc451898ccaf445814e26b46664d78702178101d /tests/ui/structs-enums
parentAdding debian version 1.71.1+dfsg1-2. (diff)
downloadrustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.tar.xz
rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.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`.