|
| 1 | +error[E0277]: the size for values of type `T` cannot be known at compilation time |
| 2 | + --> $DIR/const-argument-if-length.rs:8:28 |
| 3 | + | |
| 4 | +LL | pub const fn is_zst<T: ?Sized>() -> usize { |
| 5 | + | - this type parameter needs to be `Sized` |
| 6 | +LL | if std::mem::size_of::<T>() == 0 { |
| 7 | + | ^ doesn't have a size known at compile-time |
| 8 | + | |
| 9 | + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL |
| 10 | + | |
| 11 | +LL | pub const fn size_of<T>() -> usize { |
| 12 | + | - required by this bound in `std::mem::size_of` |
| 13 | + |
| 14 | +error[E0080]: evaluation of constant value failed |
| 15 | + --> $DIR/const-argument-if-length.rs:19:15 |
| 16 | + | |
| 17 | +LL | pad: [u8; is_zst::<T>()], |
| 18 | + | ^^^^^^^^^^^^^ referenced constant has errors |
| 19 | + |
| 20 | +error[E0277]: the size for values of type `T` cannot be known at compilation time |
| 21 | + --> $DIR/const-argument-if-length.rs:17:12 |
| 22 | + | |
| 23 | +LL | pub struct AtLeastByte<T: ?Sized> { |
| 24 | + | - this type parameter needs to be `Sized` |
| 25 | +LL | value: T, |
| 26 | + | ^ doesn't have a size known at compile-time |
| 27 | + | |
| 28 | + = note: only the last field of a struct may have a dynamically sized type |
| 29 | + = help: change the field's type to have a statically known size |
| 30 | +help: borrowed types always have a statically known size |
| 31 | + | |
| 32 | +LL | value: &T, |
| 33 | + | ^ |
| 34 | +help: the `Box` type always has a statically known size and allocates its contents in the heap |
| 35 | + | |
| 36 | +LL | value: Box<T>, |
| 37 | + | ^^^^ ^ |
| 38 | + |
| 39 | +error: aborting due to 3 previous errors |
| 40 | + |
| 41 | +Some errors have detailed explanations: E0080, E0277. |
| 42 | +For more information about an error, try `rustc --explain E0080`. |
0 commit comments