diff options
Diffstat (limited to 'tests/ui/structs-enums')
16 files changed, 162 insertions, 2 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 000000000..b7e49873d --- /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 000000000..e0a822550 --- /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 000000000..4fd786278 --- /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 000000000..ecf072b8e --- /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/rec-align-u32.rs b/tests/ui/structs-enums/rec-align-u32.rs index ee704198d..b3c323d2a 100644 --- a/tests/ui/structs-enums/rec-align-u32.rs +++ b/tests/ui/structs-enums/rec-align-u32.rs @@ -3,7 +3,7 @@ #![allow(unused_unsafe)] // Issue #2303 -#![feature(intrinsics)] +#![feature(intrinsics, rustc_attrs)] use std::mem; diff --git a/tests/ui/structs-enums/rec-align-u64.rs b/tests/ui/structs-enums/rec-align-u64.rs index f21c9b2c8..de008bcc0 100644 --- a/tests/ui/structs-enums/rec-align-u64.rs +++ b/tests/ui/structs-enums/rec-align-u64.rs @@ -5,7 +5,7 @@ // Issue #2303 -#![feature(intrinsics)] +#![feature(intrinsics, rustc_attrs)] use std::mem; @@ -37,6 +37,7 @@ struct Outer { target_os = "emscripten", target_os = "freebsd", target_os = "fuchsia", + target_os = "hurd", target_os = "illumos", target_os = "linux", target_os = "macos", 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`. |