]> git.lizzy.rs Git - rust.git/blob - src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr
Suggest boxing or borrowing unsized fields
[rust.git] / src / test / ui / suggestions / adt-param-with-implicit-sized-bound.stderr
1 error[E0277]: the size for values of type `T` cannot be known at compilation time
2   --> $DIR/adt-param-with-implicit-sized-bound.rs:25:9
3    |
4 LL | struct X<T>(T);
5    |          - required by this bound in `X`
6 ...
7 LL | struct Struct5<T: ?Sized>{
8    |                - this type parameter needs to be `std::marker::Sized`
9 LL |     _t: X<T>,
10    |         ^^^^ doesn't have a size known at compile-time
11    |
12    = help: the trait `std::marker::Sized` is not implemented for `T`
13    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
14 help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
15   --> $DIR/adt-param-with-implicit-sized-bound.rs:18:10
16    |
17 LL | struct X<T>(T);
18    |          ^  - ...if indirection was used here: `Box<T>`
19    |          |
20    |          this could be changed to `T: ?Sized`...
21
22 error[E0277]: the size for values of type `Self` cannot be known at compilation time
23   --> $DIR/adt-param-with-implicit-sized-bound.rs:2:19
24    |
25 LL |     fn func1() -> Struct1<Self>;
26    |                   ^^^^^^^^^^^^^ doesn't have a size known at compile-time
27 ...
28 LL | struct Struct1<T>{
29    |                - required by this bound in `Struct1`
30    |
31    = help: the trait `std::marker::Sized` is not implemented for `Self`
32    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
33 help: consider further restricting `Self`
34    |
35 LL |     fn func1() -> Struct1<Self> where Self: std::marker::Sized;
36    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
37 help: consider relaxing the implicit `Sized` restriction
38    |
39 LL | struct Struct1<T: ?Sized>{
40    |                 ^^^^^^^^
41
42 error[E0277]: the size for values of type `Self` cannot be known at compilation time
43   --> $DIR/adt-param-with-implicit-sized-bound.rs:3:23
44    |
45 LL |     fn func2<'a>() -> Struct2<'a, Self>;
46    |                       ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
47 ...
48 LL | struct Struct2<'a, T>{
49    |                    - required by this bound in `Struct2`
50    |
51    = help: the trait `std::marker::Sized` is not implemented for `Self`
52    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
53 help: consider further restricting `Self`
54    |
55 LL |     fn func2<'a>() -> Struct2<'a, Self> where Self: std::marker::Sized;
56    |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
57 help: consider relaxing the implicit `Sized` restriction
58    |
59 LL | struct Struct2<'a, T: ?Sized>{
60    |                     ^^^^^^^^
61
62 error[E0277]: the size for values of type `Self` cannot be known at compilation time
63   --> $DIR/adt-param-with-implicit-sized-bound.rs:4:19
64    |
65 LL |     fn func3() -> Struct3<Self>;
66    |                   ^^^^^^^^^^^^^ doesn't have a size known at compile-time
67 ...
68 LL | struct Struct3<T>{
69    |                - required by this bound in `Struct3`
70    |
71    = help: the trait `std::marker::Sized` is not implemented for `Self`
72    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
73 help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
74   --> $DIR/adt-param-with-implicit-sized-bound.rs:14:16
75    |
76 LL | struct Struct3<T>{
77    |                ^ this could be changed to `T: ?Sized`...
78 LL |     _t: T,
79    |         - ...if indirection was used here: `Box<T>`
80 help: consider further restricting `Self`
81    |
82 LL |     fn func3() -> Struct3<Self> where Self: std::marker::Sized;
83    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
84
85 error[E0277]: the size for values of type `Self` cannot be known at compilation time
86   --> $DIR/adt-param-with-implicit-sized-bound.rs:5:19
87    |
88 LL |     fn func4() -> Struct4<Self>;
89    |                   ^^^^^^^^^^^^^ doesn't have a size known at compile-time
90 ...
91 LL | struct Struct4<T>{
92    |                - required by this bound in `Struct4`
93    |
94    = help: the trait `std::marker::Sized` is not implemented for `Self`
95    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
96 help: consider further restricting `Self`
97    |
98 LL |     fn func4() -> Struct4<Self> where Self: std::marker::Sized;
99    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
100 help: consider relaxing the implicit `Sized` restriction
101    |
102 LL | struct Struct4<T: ?Sized>{
103    |                 ^^^^^^^^
104
105 error: aborting due to 5 previous errors
106
107 For more information about this error, try `rustc --explain E0277`.