]> git.lizzy.rs Git - rust.git/blob - src/test/ui/union/union-unsized.stderr
Suggest boxing or borrowing unsized fields
[rust.git] / src / test / ui / union / union-unsized.stderr
1 error[E0277]: the size for values of type `str` cannot be known at compilation time
2   --> $DIR/union-unsized.rs:4:8
3    |
4 LL |     a: str,
5    |        ^^^ doesn't have a size known at compile-time
6    |
7    = help: the trait `std::marker::Sized` is not implemented for `str`
8    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
9    = note: no field of a union may have a dynamically sized type
10    = help: change the field's type to have a statically known size
11 help: borrowed types always have a statically known size
12    |
13 LL |     a: &str,
14    |        ^
15 help: heap allocated types always have a statically known size
16    |
17 LL |     a: Box<str>,
18    |        ^^^^   ^
19
20 error[E0277]: the size for values of type `str` cannot be known at compilation time
21   --> $DIR/union-unsized.rs:12:8
22    |
23 LL |     b: str,
24    |        ^^^ doesn't have a size known at compile-time
25    |
26    = help: the trait `std::marker::Sized` is not implemented for `str`
27    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
28    = note: no field of a union 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 |     b: &str,
33    |        ^
34 help: heap allocated types always have a statically known size
35    |
36 LL |     b: Box<str>,
37    |        ^^^^   ^
38
39 error: aborting due to 2 previous errors
40
41 For more information about this error, try `rustc --explain E0277`.