1 error[E0277]: the size for values of type `T` cannot be known at compilation time
2 --> $DIR/union-sized-field.rs:4:12
4 LL | union Foo<T: ?Sized> {
5 | - this type parameter needs to be `std::marker::Sized`
6 LL | value: ManuallyDrop<T>,
7 | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
9 = note: required because it appears within the type `ManuallyDrop<T>`
10 = note: no field of a union may have a dynamically sized type
11 = help: change the field's type to have a statically known size
12 help: consider removing the `?Sized` bound to make the type parameter `Sized`
14 LL - union Foo<T: ?Sized> {
17 help: borrowed types always have a statically known size
19 LL | value: &ManuallyDrop<T>,
21 help: the `Box` type always has a statically known size and allocates its contents in the heap
23 LL | value: Box<ManuallyDrop<T>>,
26 error[E0277]: the size for values of type `T` cannot be known at compilation time
27 --> $DIR/union-sized-field.rs:9:12
29 LL | struct Foo2<T: ?Sized> {
30 | - this type parameter needs to be `std::marker::Sized`
31 LL | value: ManuallyDrop<T>,
32 | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
34 = note: required because it appears within the type `ManuallyDrop<T>`
35 = note: only the last field of a struct may have a dynamically sized type
36 = help: change the field's type to have a statically known size
37 help: consider removing the `?Sized` bound to make the type parameter `Sized`
39 LL - struct Foo2<T: ?Sized> {
42 help: borrowed types always have a statically known size
44 LL | value: &ManuallyDrop<T>,
46 help: the `Box` type always has a statically known size and allocates its contents in the heap
48 LL | value: Box<ManuallyDrop<T>>,
51 error[E0277]: the size for values of type `T` cannot be known at compilation time
52 --> $DIR/union-sized-field.rs:15:11
54 LL | enum Foo3<T: ?Sized> {
55 | - this type parameter needs to be `std::marker::Sized`
56 LL | Value(ManuallyDrop<T>),
57 | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
59 = note: required because it appears within the type `ManuallyDrop<T>`
60 = note: no field of an enum variant may have a dynamically sized type
61 = help: change the field's type to have a statically known size
62 help: consider removing the `?Sized` bound to make the type parameter `Sized`
64 LL - enum Foo3<T: ?Sized> {
67 help: borrowed types always have a statically known size
69 LL | Value(&ManuallyDrop<T>),
71 help: the `Box` type always has a statically known size and allocates its contents in the heap
73 LL | Value(Box<ManuallyDrop<T>>),
76 error: aborting due to 3 previous errors
78 For more information about this error, try `rustc --explain E0277`.