1
1
error[E0277]: the size for values of type `T` cannot be known at compilation time
2
- --> $DIR/union-sized-field.rs:4:5
2
+ --> $DIR/union-sized-field.rs:4:12
3
3
|
4
4
LL | union Foo<T: ?Sized> {
5
5
| - this type parameter needs to be `std::marker::Sized`
6
6
LL | value: T,
7
- | ^^^^^^^ ^ doesn't have a size known at compile-time
7
+ | ^ doesn't have a size known at compile-time
8
8
|
9
9
= help: the trait `std::marker::Sized` is not implemented for `T`
10
10
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
11
11
= note: no field of a union may have a dynamically sized type
12
+ = help: change the field's type to have a statically known size
13
+ help: borrowed types always have a statically known size
14
+ |
15
+ LL | value: &T,
16
+ | ^
17
+ help: heap allocated types always have a statically known size
18
+ |
19
+ LL | value: Box<T>,
20
+ | ^^^^ ^
12
21
13
22
error[E0277]: the size for values of type `T` cannot be known at compilation time
14
- --> $DIR/union-sized-field.rs:9:5
23
+ --> $DIR/union-sized-field.rs:9:12
15
24
|
16
25
LL | struct Foo2<T: ?Sized> {
17
26
| - this type parameter needs to be `std::marker::Sized`
18
27
LL | value: T,
19
- | ^^^^^^^ ^ doesn't have a size known at compile-time
28
+ | ^ doesn't have a size known at compile-time
20
29
|
21
30
= help: the trait `std::marker::Sized` is not implemented for `T`
22
31
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
23
32
= note: only the last field of a struct may have a dynamically sized type
33
+ = help: change the field's type to have a statically known size
34
+ help: borrowed types always have a statically known size
35
+ |
36
+ LL | value: &T,
37
+ | ^
38
+ help: heap allocated types always have a statically known size
39
+ |
40
+ LL | value: Box<T>,
41
+ | ^^^^ ^
24
42
25
43
error[E0277]: the size for values of type `T` cannot be known at compilation time
26
44
--> $DIR/union-sized-field.rs:15:11
@@ -33,6 +51,15 @@ LL | Value(T),
33
51
= help: the trait `std::marker::Sized` is not implemented for `T`
34
52
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
35
53
= note: no field of an enum variant may have a dynamically sized type
54
+ = help: change the field's type to have a statically known size
55
+ help: borrowed types always have a statically known size
56
+ |
57
+ LL | Value(&T),
58
+ | ^
59
+ help: heap allocated types always have a statically known size
60
+ |
61
+ LL | Value(Box<T>),
62
+ | ^^^^ ^
36
63
37
64
error: aborting due to 3 previous errors
38
65
0 commit comments