]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/const-argument-if-length.full.stderr
Auto merge of #87150 - rusticstuff:simplify_wrapping_neg, r=m-ou-se
[rust.git] / src / test / ui / const-generics / const-argument-if-length.full.stderr
1 error[E0277]: the size for values of type `T` cannot be known at compilation time
2   --> $DIR/const-argument-if-length.rs:7:28
3    |
4 LL | pub const fn is_zst<T: ?Sized>() -> usize {
5    |                     - this type parameter needs to be `std::marker::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 help: consider removing the `?Sized` bound to make the type parameter `Sized`
15    |
16 LL | pub const fn is_zst<T>() -> usize {
17    |                     --
18
19 error[E0277]: the size for values of type `T` cannot be known at compilation time
20   --> $DIR/const-argument-if-length.rs:16:12
21    |
22 LL | pub struct AtLeastByte<T: ?Sized> {
23    |                        - this type parameter needs to be `std::marker::Sized`
24 LL |     value: T,
25    |            ^ doesn't have a size known at compile-time
26    |
27    = note: only the last field of a struct may have a dynamically sized type
28    = help: change the field's type to have a statically known size
29 help: consider removing the `?Sized` bound to make the type parameter `Sized`
30    |
31 LL | pub struct AtLeastByte<T> {
32    |                        --
33 help: borrowed types always have a statically known size
34    |
35 LL |     value: &T,
36    |            ^
37 help: the `Box` type always has a statically known size and allocates its contents in the heap
38    |
39 LL |     value: Box<T>,
40    |            ^^^^ ^
41
42 error: aborting due to 2 previous errors
43
44 For more information about this error, try `rustc --explain E0277`.