about summary refs log tree commit diff
path: root/tests/ui/structs-enums
diff options
context:
space:
mode:
authorOlanti <olanti-p@yandex.ru>2023-08-24 02:05:32 +0300
committerOlanti <olanti-p@yandex.ru>2023-08-24 20:44:08 +0300
commit8216f17d7d09d1ac6224b99c0ebf719ed276e4a7 (patch)
treeb547832193487aa600e6ff1da25a9b06f8683eba /tests/ui/structs-enums
parent0510a1526d4135861226281eed38114ab71a12f0 (diff)
downloadrust-8216f17d7d09d1ac6224b99c0ebf719ed276e4a7.tar.gz
rust-8216f17d7d09d1ac6224b99c0ebf719ed276e4a7.zip
Move issue 29181, 2804, 17431, 66768
Diffstat (limited to 'tests/ui/structs-enums')
-rw-r--r--tests/ui/structs-enums/enum-rec/issue-17431-6.rs8
-rw-r--r--tests/ui/structs-enums/enum-rec/issue-17431-6.stderr14
-rw-r--r--tests/ui/structs-enums/enum-rec/issue-17431-7.rs6
-rw-r--r--tests/ui/structs-enums/enum-rec/issue-17431-7.stderr14
-rw-r--r--tests/ui/structs-enums/struct-rec/issue-17431-1.rs6
-rw-r--r--tests/ui/structs-enums/struct-rec/issue-17431-1.stderr14
-rw-r--r--tests/ui/structs-enums/struct-rec/issue-17431-2.rs8
-rw-r--r--tests/ui/structs-enums/struct-rec/issue-17431-2.stderr20
-rw-r--r--tests/ui/structs-enums/struct-rec/issue-17431-3.rs8
-rw-r--r--tests/ui/structs-enums/struct-rec/issue-17431-3.stderr14
-rw-r--r--tests/ui/structs-enums/struct-rec/issue-17431-4.rs8
-rw-r--r--tests/ui/structs-enums/struct-rec/issue-17431-4.stderr14
-rw-r--r--tests/ui/structs-enums/struct-rec/issue-17431-5.rs11
-rw-r--r--tests/ui/structs-enums/struct-rec/issue-17431-5.stderr14
14 files changed, 159 insertions, 0 deletions
diff --git a/tests/ui/structs-enums/enum-rec/issue-17431-6.rs b/tests/ui/structs-enums/enum-rec/issue-17431-6.rs
new file mode 100644
index 00000000000..b7e49873da8
--- /dev/null
+++ b/tests/ui/structs-enums/enum-rec/issue-17431-6.rs
@@ -0,0 +1,8 @@
+use std::sync::Mutex;
+
+enum Foo { X(Mutex<Option<Foo>>) }
+//~^ ERROR recursive type `Foo` has infinite size
+
+impl Foo { fn bar(self) {} }
+
+fn main() {}
diff --git a/tests/ui/structs-enums/enum-rec/issue-17431-6.stderr b/tests/ui/structs-enums/enum-rec/issue-17431-6.stderr
new file mode 100644
index 00000000000..e0a8225507e
--- /dev/null
+++ b/tests/ui/structs-enums/enum-rec/issue-17431-6.stderr
@@ -0,0 +1,14 @@
+error[E0072]: recursive type `Foo` has infinite size
+  --> $DIR/issue-17431-6.rs:3:1
+   |
+LL | enum Foo { X(Mutex<Option<Foo>>) }
+   | ^^^^^^^^                  --- recursive without indirection
+   |
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
+   |
+LL | enum Foo { X(Mutex<Option<Box<Foo>>>) }
+   |                           ++++   +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0072`.
diff --git a/tests/ui/structs-enums/enum-rec/issue-17431-7.rs b/tests/ui/structs-enums/enum-rec/issue-17431-7.rs
new file mode 100644
index 00000000000..4fd7862781b
--- /dev/null
+++ b/tests/ui/structs-enums/enum-rec/issue-17431-7.rs
@@ -0,0 +1,6 @@
+enum Foo { Voo(Option<Option<Foo>>) }
+//~^ ERROR recursive type `Foo` has infinite size
+
+impl Foo { fn bar(&self) {} }
+
+fn main() { }
diff --git a/tests/ui/structs-enums/enum-rec/issue-17431-7.stderr b/tests/ui/structs-enums/enum-rec/issue-17431-7.stderr
new file mode 100644
index 00000000000..ecf072b8e8a
--- /dev/null
+++ b/tests/ui/structs-enums/enum-rec/issue-17431-7.stderr
@@ -0,0 +1,14 @@
+error[E0072]: recursive type `Foo` has infinite size
+  --> $DIR/issue-17431-7.rs:1:1
+   |
+LL | enum Foo { Voo(Option<Option<Foo>>) }
+   | ^^^^^^^^                     --- recursive without indirection
+   |
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
+   |
+LL | enum Foo { Voo(Option<Option<Box<Foo>>>) }
+   |                              ++++   +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0072`.
diff --git a/tests/ui/structs-enums/struct-rec/issue-17431-1.rs b/tests/ui/structs-enums/struct-rec/issue-17431-1.rs
new file mode 100644
index 00000000000..3b692cc0eeb
--- /dev/null
+++ b/tests/ui/structs-enums/struct-rec/issue-17431-1.rs
@@ -0,0 +1,6 @@
+struct Foo { foo: Option<Option<Foo>> }
+//~^ ERROR recursive type `Foo` has infinite size
+
+impl Foo { fn bar(&self) {} }
+
+fn main() {}
diff --git a/tests/ui/structs-enums/struct-rec/issue-17431-1.stderr b/tests/ui/structs-enums/struct-rec/issue-17431-1.stderr
new file mode 100644
index 00000000000..e3af8976cee
--- /dev/null
+++ b/tests/ui/structs-enums/struct-rec/issue-17431-1.stderr
@@ -0,0 +1,14 @@
+error[E0072]: recursive type `Foo` has infinite size
+  --> $DIR/issue-17431-1.rs:1:1
+   |
+LL | struct Foo { foo: Option<Option<Foo>> }
+   | ^^^^^^^^^^                      --- recursive without indirection
+   |
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
+   |
+LL | struct Foo { foo: Option<Option<Box<Foo>>> }
+   |                                 ++++   +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0072`.
diff --git a/tests/ui/structs-enums/struct-rec/issue-17431-2.rs b/tests/ui/structs-enums/struct-rec/issue-17431-2.rs
new file mode 100644
index 00000000000..f7b9c6a55dd
--- /dev/null
+++ b/tests/ui/structs-enums/struct-rec/issue-17431-2.rs
@@ -0,0 +1,8 @@
+struct Baz { q: Option<Foo> }
+//~^ ERROR recursive types `Baz` and `Foo` have infinite size
+
+struct Foo { q: Option<Baz> }
+
+impl Foo { fn bar(&self) {} }
+
+fn main() {}
diff --git a/tests/ui/structs-enums/struct-rec/issue-17431-2.stderr b/tests/ui/structs-enums/struct-rec/issue-17431-2.stderr
new file mode 100644
index 00000000000..39a99ec1ef7
--- /dev/null
+++ b/tests/ui/structs-enums/struct-rec/issue-17431-2.stderr
@@ -0,0 +1,20 @@
+error[E0072]: recursive types `Baz` and `Foo` have infinite size
+  --> $DIR/issue-17431-2.rs:1:1
+   |
+LL | struct Baz { q: Option<Foo> }
+   | ^^^^^^^^^^             --- recursive without indirection
+...
+LL | struct Foo { q: Option<Baz> }
+   | ^^^^^^^^^^             --- recursive without indirection
+   |
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
+   |
+LL ~ struct Baz { q: Option<Box<Foo>> }
+LL |
+LL | 
+LL ~ struct Foo { q: Option<Box<Baz>> }
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0072`.
diff --git a/tests/ui/structs-enums/struct-rec/issue-17431-3.rs b/tests/ui/structs-enums/struct-rec/issue-17431-3.rs
new file mode 100644
index 00000000000..83a63a88b72
--- /dev/null
+++ b/tests/ui/structs-enums/struct-rec/issue-17431-3.rs
@@ -0,0 +1,8 @@
+use std::sync::Mutex;
+
+struct Foo { foo: Mutex<Option<Foo>> }
+//~^ ERROR recursive type `Foo` has infinite size
+
+impl Foo { fn bar(&self) {} }
+
+fn main() {}
diff --git a/tests/ui/structs-enums/struct-rec/issue-17431-3.stderr b/tests/ui/structs-enums/struct-rec/issue-17431-3.stderr
new file mode 100644
index 00000000000..394134c7855
--- /dev/null
+++ b/tests/ui/structs-enums/struct-rec/issue-17431-3.stderr
@@ -0,0 +1,14 @@
+error[E0072]: recursive type `Foo` has infinite size
+  --> $DIR/issue-17431-3.rs:3:1
+   |
+LL | struct Foo { foo: Mutex<Option<Foo>> }
+   | ^^^^^^^^^^                     --- recursive without indirection
+   |
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
+   |
+LL | struct Foo { foo: Mutex<Option<Box<Foo>>> }
+   |                                ++++   +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0072`.
diff --git a/tests/ui/structs-enums/struct-rec/issue-17431-4.rs b/tests/ui/structs-enums/struct-rec/issue-17431-4.rs
new file mode 100644
index 00000000000..48f0dba2aec
--- /dev/null
+++ b/tests/ui/structs-enums/struct-rec/issue-17431-4.rs
@@ -0,0 +1,8 @@
+use std::marker;
+
+struct Foo<T> { foo: Option<Option<Foo<T>>>, marker: marker::PhantomData<T> }
+//~^ ERROR recursive type `Foo` has infinite size
+
+impl<T> Foo<T> { fn bar(&self) {} }
+
+fn main() {}
diff --git a/tests/ui/structs-enums/struct-rec/issue-17431-4.stderr b/tests/ui/structs-enums/struct-rec/issue-17431-4.stderr
new file mode 100644
index 00000000000..3d141e44bab
--- /dev/null
+++ b/tests/ui/structs-enums/struct-rec/issue-17431-4.stderr
@@ -0,0 +1,14 @@
+error[E0072]: recursive type `Foo` has infinite size
+  --> $DIR/issue-17431-4.rs:3:1
+   |
+LL | struct Foo<T> { foo: Option<Option<Foo<T>>>, marker: marker::PhantomData<T> }
+   | ^^^^^^^^^^^^^                      ------ recursive without indirection
+   |
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
+   |
+LL | struct Foo<T> { foo: Option<Option<Box<Foo<T>>>>, marker: marker::PhantomData<T> }
+   |                                    ++++      +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0072`.
diff --git a/tests/ui/structs-enums/struct-rec/issue-17431-5.rs b/tests/ui/structs-enums/struct-rec/issue-17431-5.rs
new file mode 100644
index 00000000000..0fd6ee61156
--- /dev/null
+++ b/tests/ui/structs-enums/struct-rec/issue-17431-5.rs
@@ -0,0 +1,11 @@
+use std::marker;
+
+struct Foo { foo: Bar<Foo> }
+
+struct Bar<T> { x: Bar<Foo> , marker: marker::PhantomData<T> }
+//~^ ERROR recursive type `Bar` has infinite size
+
+impl Foo { fn foo(&self) {} }
+
+fn main() {
+}
diff --git a/tests/ui/structs-enums/struct-rec/issue-17431-5.stderr b/tests/ui/structs-enums/struct-rec/issue-17431-5.stderr
new file mode 100644
index 00000000000..44a90a6fe38
--- /dev/null
+++ b/tests/ui/structs-enums/struct-rec/issue-17431-5.stderr
@@ -0,0 +1,14 @@
+error[E0072]: recursive type `Bar` has infinite size
+  --> $DIR/issue-17431-5.rs:5:1
+   |
+LL | struct Bar<T> { x: Bar<Foo> , marker: marker::PhantomData<T> }
+   | ^^^^^^^^^^^^^      -------- recursive without indirection
+   |
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
+   |
+LL | struct Bar<T> { x: Box<Bar<Foo>> , marker: marker::PhantomData<T> }
+   |                    ++++        +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0072`.