summaryrefslogtreecommitdiffstats
path: root/tests/ui/structs-enums/struct-rec
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/structs-enums/struct-rec')
-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
10 files changed, 117 insertions, 0 deletions
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 000000000..3b692cc0e
--- /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 000000000..e3af8976c
--- /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 000000000..f7b9c6a55
--- /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 000000000..39a99ec1e
--- /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 000000000..83a63a88b
--- /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 000000000..394134c78
--- /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 000000000..48f0dba2a
--- /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 000000000..3d141e44b
--- /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 000000000..0fd6ee611
--- /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 000000000..44a90a6fe
--- /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`.