/// Types of fields (other than the last, except for packed structs) in a struct must be sized.
FieldSized {
adt_kind: AdtKind,
+ span: Span,
last: bool,
},
super::SizedYieldType => Some(super::SizedYieldType),
super::InlineAsmSized => Some(super::InlineAsmSized),
super::RepeatVec(suggest_flag) => Some(super::RepeatVec(suggest_flag)),
- super::FieldSized { adt_kind, last } => Some(super::FieldSized { adt_kind, last }),
+ super::FieldSized { adt_kind, span, last } => {
+ Some(super::FieldSized { adt_kind, span, last })
+ }
super::ConstSized => Some(super::ConstSized),
super::ConstPatternStructural => Some(super::ConstPatternStructural),
super::SharedStatic => Some(super::SharedStatic),
ObligationCauseCode::StructInitializerSized => {
err.note("structs must have a statically known size to be initialized");
}
- ObligationCauseCode::FieldSized { adt_kind: ref item, last } => match *item {
- AdtKind::Struct => {
- if last {
- err.note(
- "the last field of a packed struct may only have a \
- dynamically sized type if it does not need drop to be run",
- );
- } else {
- err.note(
- "only the last field of a struct may have a dynamically sized type",
- );
+ ObligationCauseCode::FieldSized { adt_kind: ref item, last, span } => {
+ match *item {
+ AdtKind::Struct => {
+ if last {
+ err.note(
+ "the last field of a packed struct may only have a \
+ dynamically sized type if it does not need drop to be run",
+ );
+ } else {
+ err.note(
+ "only the last field of a struct may have a dynamically sized type",
+ );
+ }
+ }
+ AdtKind::Union => {
+ err.note("no field of a union may have a dynamically sized type");
+ }
+ AdtKind::Enum => {
+ err.note("no field of an enum variant may have a dynamically sized type");
}
}
- AdtKind::Union => {
- err.note("no field of a union may have a dynamically sized type");
- }
- AdtKind::Enum => {
- err.note("no field of an enum variant may have a dynamically sized type");
- }
- },
+ err.help("change the field's type to have a statically known size");
+ err.span_suggestion(
+ span.shrink_to_lo(),
+ "borrowed types always have a statically known size",
+ "&".to_string(),
+ Applicability::MachineApplicable,
+ );
+ err.multipart_suggestion(
+ "heap allocated types always have a statically known size",
+ vec![
+ (span.shrink_to_lo(), "Box<".to_string()),
+ (span.shrink_to_hi(), ">".to_string()),
+ ],
+ Applicability::MachineApplicable,
+ );
+ }
ObligationCauseCode::ConstSized => {
err.note("constant expressions must have a statically known size");
}
Some(i) => i,
None => bug!(),
},
+ span: field.span,
last,
},
),
let field_ty = self.normalize_associated_types_in(field.ty.span, &field_ty);
let field_ty = self.resolve_vars_if_possible(&field_ty);
debug!("non_enum_variant: type of field {:?} is {:?}", field, field_ty);
- AdtField { ty: field_ty, span: field.span }
+ AdtField { ty: field_ty, span: field.ty.span }
})
.collect();
AdtVariant { fields, explicit_discr: None }
= note: this may fail depending on what value the parameter takes
error: constant expression depends on a generic parameter
- --> $DIR/array-size-in-generic-struct-param.rs:14:5
+ --> $DIR/array-size-in-generic-struct-param.rs:14:10
|
LL | arr: [u8; CFG.arr_size],
- | ^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes
error[E0478]: lifetime bound not satisfied
- --> $DIR/E0478.rs:4:5
+ --> $DIR/E0478.rs:4:12
|
LL | child: Box<dyn Wedding<'kiss> + 'SnowWhite>,
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lifetime parameter instantiated with the lifetime `'SnowWhite` as defined on the struct at 3:22
--> $DIR/E0478.rs:3:22
error[E0310]: the parameter type `U` may not live long enough
- --> $DIR/feature-gate-infer_static_outlives_requirements.rs:5:5
+ --> $DIR/feature-gate-infer_static_outlives_requirements.rs:5:10
|
LL | struct Foo<U> {
| - help: consider adding an explicit lifetime bound...: `U: 'static`
LL | bar: Bar<U>
- | ^^^^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds
+ | ^^^^^^ ...so that the type `U` will meet its required lifetime bounds
error: aborting due to previous error
error[E0038]: the trait `Qiz` cannot be made into an object
- --> $DIR/issue-19380.rs:11:3
+ --> $DIR/issue-19380.rs:11:9
|
LL | trait Qiz {
| --- this trait cannot be made into an object...
| --- ...because associated function `qiz` has no `self` parameter
...
LL | foos: &'static [&'static (dyn Qiz + 'static)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Qiz` cannot be made into an object
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Qiz` cannot be made into an object
|
help: consider turning `qiz` into a method by giving it a `&self` argument or constraining it so it does not apply to trait objects
|
error[E0277]: the size for values of type `[std::string::String]` cannot be known at compilation time
- --> $DIR/issue-22874.rs:2:5
+ --> $DIR/issue-22874.rs:2:11
|
LL | rows: [[String]],
- | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+ | ^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `[std::string::String]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
error[E0277]: the size for values of type `T` cannot be known at compilation time
- --> $DIR/issue-27060-2.rs:3:5
+ --> $DIR/issue-27060-2.rs:3:11
|
LL | pub struct Bad<T: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
LL | data: T,
- | ^^^^^^^ doesn't have a size known at compile-time
+ | ^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `T`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: the last field of a packed struct may only have a dynamically sized type if it does not need drop to be run
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | data: &T,
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | data: Box<T>,
+ | ^^^^ ^
error: aborting due to previous error
= help: the trait `std::marker::Sized` is not implemented for `[std::boxed::Box<E>]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | V(&[Box<E>]),
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | V(Box<[Box<E>]>),
+ | ^^^^ ^
error: aborting due to previous error
= note: see issue #72219 <https://github.com/rust-lang/rust/issues/72219> for more information
error: constant expression depends on a generic parameter
- --> $DIR/issue-57739.rs:12:5
+ --> $DIR/issue-57739.rs:12:12
|
LL | array: [u8; T::SIZE],
- | ^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes
error[E0310]: the parameter type `T` may not live long enough
- --> $DIR/lifetime-doesnt-live-long-enough.rs:19:5
+ --> $DIR/lifetime-doesnt-live-long-enough.rs:19:10
|
LL | struct Foo<T> {
| - help: consider adding an explicit lifetime bound...: `T: 'static`
LL | foo: &'static T
- | ^^^^^^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at
+ | ^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at
error[E0309]: the parameter type `K` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:24:19
| ^^
error[E0478]: lifetime bound not satisfied
- --> $DIR/region-bounds-on-objects-and-type-parameters.rs:21:5
+ --> $DIR/region-bounds-on-objects-and-type-parameters.rs:21:8
|
LL | z: Box<dyn Is<'a>+'b+'c>,
- | ^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^
|
note: lifetime parameter instantiated with the lifetime `'b` as defined on the struct at 11:15
--> $DIR/region-bounds-on-objects-and-type-parameters.rs:11:15
error[E0478]: lifetime bound not satisfied
- --> $DIR/regions-wf-trait-object.rs:7:5
+ --> $DIR/regions-wf-trait-object.rs:7:8
|
LL | x: Box<dyn TheTrait<'a>+'b>
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lifetime parameter instantiated with the lifetime `'b` as defined on the struct at 6:15
--> $DIR/regions-wf-trait-object.rs:6:15
error[E0310]: the parameter type `U` may not live long enough
- --> $DIR/dont-infer-static.rs:8:5
+ --> $DIR/dont-infer-static.rs:8:10
|
LL | struct Foo<U> {
| - help: consider adding an explicit lifetime bound...: `U: 'static`
LL | bar: Bar<U>
- | ^^^^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds
+ | ^^^^^^ ...so that the type `U` will meet its required lifetime bounds
error: aborting due to previous error
error[E0277]: the size for values of type `T` cannot be known at compilation time
- --> $DIR/adt-param-with-implicit-sized-bound.rs:25:5
+ --> $DIR/adt-param-with-implicit-sized-bound.rs:25:9
|
LL | struct X<T>(T);
| - required by this bound in `X`
LL | struct Struct5<T: ?Sized>{
| - this type parameter needs to be `std::marker::Sized`
LL | _t: X<T>,
- | ^^^^^^^^ doesn't have a size known at compile-time
+ | ^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `T`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
| ^^^^^^^
error[E0277]: the trait bound `isize: Trait` is not satisfied
- --> $DIR/trait-bounds-on-structs-and-enums.rs:19:5
+ --> $DIR/trait-bounds-on-structs-and-enums.rs:19:8
|
LL | struct Foo<T:Trait> {
| ----- required by this bound in `Foo`
...
LL | a: Foo<isize>,
- | ^^^^^^^^^^^^^ the trait `Trait` is not implemented for `isize`
+ | ^^^^^^^^^^ the trait `Trait` is not implemented for `isize`
error[E0277]: the trait bound `usize: Trait` is not satisfied
--> $DIR/trait-bounds-on-structs-and-enums.rs:23:10
| ^^^^^^^^^^ the trait `Trait` is not implemented for `usize`
error[E0277]: the trait bound `U: Trait` is not satisfied
- --> $DIR/trait-bounds-on-structs-and-enums.rs:27:5
+ --> $DIR/trait-bounds-on-structs-and-enums.rs:27:8
|
LL | struct Foo<T:Trait> {
| ----- required by this bound in `Foo`
...
LL | b: Foo<U>,
- | ^^^^^^^^^ the trait `Trait` is not implemented for `U`
+ | ^^^^^^ the trait `Trait` is not implemented for `U`
|
help: consider restricting type parameter `U`
|
| ^^^^^^^^ the trait `Trait` is not implemented for `i32`
error[E0277]: the trait bound `u8: Trait` is not satisfied
- --> $DIR/trait-bounds-on-structs-and-enums.rs:39:22
+ --> $DIR/trait-bounds-on-structs-and-enums.rs:39:29
|
LL | enum Bar<T:Trait> {
| ----- required by this bound in `Bar`
...
LL | DictionaryLike { field: Bar<u8> },
- | ^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `u8`
+ | ^^^^^^^ the trait `Trait` is not implemented for `u8`
error: aborting due to 7 previous errors
error[E0277]: the size for values of type `T` cannot be known at compilation time
- --> $DIR/union-sized-field.rs:4:5
+ --> $DIR/union-sized-field.rs:4:12
|
LL | union Foo<T: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
LL | value: T,
- | ^^^^^^^^ doesn't have a size known at compile-time
+ | ^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `T`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of a union may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | value: &T,
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | value: Box<T>,
+ | ^^^^ ^
error[E0277]: the size for values of type `T` cannot be known at compilation time
- --> $DIR/union-sized-field.rs:9:5
+ --> $DIR/union-sized-field.rs:9:12
|
LL | struct Foo2<T: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
LL | value: T,
- | ^^^^^^^^ doesn't have a size known at compile-time
+ | ^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `T`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: only the last field of a struct may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | value: &T,
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | value: Box<T>,
+ | ^^^^ ^
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> $DIR/union-sized-field.rs:15:11
= help: the trait `std::marker::Sized` is not implemented for `T`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | Value(&T),
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | Value(Box<T>),
+ | ^^^^ ^
error: aborting due to 3 previous errors
error[E0277]: the size for values of type `str` cannot be known at compilation time
- --> $DIR/union-unsized.rs:4:5
+ --> $DIR/union-unsized.rs:4:8
|
LL | a: str,
- | ^^^^^^ doesn't have a size known at compile-time
+ | ^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `str`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of a union may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | a: &str,
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | a: Box<str>,
+ | ^^^^ ^
error[E0277]: the size for values of type `str` cannot be known at compilation time
- --> $DIR/union-unsized.rs:12:5
+ --> $DIR/union-unsized.rs:12:8
|
LL | b: str,
- | ^^^^^^ doesn't have a size known at compile-time
+ | ^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `str`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of a union may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | b: &str,
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | b: Box<str>,
+ | ^^^^ ^
error: aborting due to 2 previous errors
= help: the trait `std::marker::Sized` is not implemented for `W`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VA(&W),
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VA(Box<W>),
+ | ^^^^ ^
error[E0277]: the size for values of type `X` cannot be known at compilation time
- --> $DIR/unsized-enum2.rs:25:8
+ --> $DIR/unsized-enum2.rs:25:11
|
LL | enum E<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
...
LL | VB{x: X},
- | ^^^^ doesn't have a size known at compile-time
+ | ^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `X`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VB{x: &X},
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VB{x: Box<X>},
+ | ^^^^ ^
error[E0277]: the size for values of type `Y` cannot be known at compilation time
--> $DIR/unsized-enum2.rs:27:15
= help: the trait `std::marker::Sized` is not implemented for `Y`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VC(isize, &Y),
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VC(isize, Box<Y>),
+ | ^^^^ ^
error[E0277]: the size for values of type `Z` cannot be known at compilation time
- --> $DIR/unsized-enum2.rs:29:18
+ --> $DIR/unsized-enum2.rs:29:21
|
LL | enum E<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
...
LL | VD{u: isize, x: Z},
- | ^^^^ doesn't have a size known at compile-time
+ | ^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `Z`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VD{u: isize, x: &Z},
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VD{u: isize, x: Box<Z>},
+ | ^^^^ ^
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> $DIR/unsized-enum2.rs:33:8
= help: the trait `std::marker::Sized` is not implemented for `[u8]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VE(&[u8]),
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VE(Box<[u8]>),
+ | ^^^^ ^
error[E0277]: the size for values of type `str` cannot be known at compilation time
- --> $DIR/unsized-enum2.rs:35:8
+ --> $DIR/unsized-enum2.rs:35:11
|
LL | VF{x: str},
- | ^^^^^^ doesn't have a size known at compile-time
+ | ^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `str`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VF{x: &str},
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VF{x: Box<str>},
+ | ^^^^ ^
error[E0277]: the size for values of type `[f32]` cannot be known at compilation time
--> $DIR/unsized-enum2.rs:37:15
= help: the trait `std::marker::Sized` is not implemented for `[f32]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VG(isize, &[f32]),
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VG(isize, Box<[f32]>),
+ | ^^^^ ^
error[E0277]: the size for values of type `[u32]` cannot be known at compilation time
- --> $DIR/unsized-enum2.rs:39:18
+ --> $DIR/unsized-enum2.rs:39:21
|
LL | VH{u: isize, x: [u32]},
- | ^^^^^^^^ doesn't have a size known at compile-time
+ | ^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `[u32]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VH{u: isize, x: &[u32]},
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VH{u: isize, x: Box<[u32]>},
+ | ^^^^ ^
error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time
--> $DIR/unsized-enum2.rs:53:8
= help: the trait `std::marker::Sized` is not implemented for `(dyn Foo + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VM(&dyn Foo),
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VM(Box<dyn Foo>),
+ | ^^^^ ^
error[E0277]: the size for values of type `(dyn Bar + 'static)` cannot be known at compilation time
- --> $DIR/unsized-enum2.rs:55:8
+ --> $DIR/unsized-enum2.rs:55:11
|
LL | VN{x: dyn Bar},
- | ^^^^^^^^^^ doesn't have a size known at compile-time
+ | ^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `(dyn Bar + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VN{x: &dyn Bar},
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VN{x: Box<dyn Bar>},
+ | ^^^^ ^
error[E0277]: the size for values of type `(dyn FooBar + 'static)` cannot be known at compilation time
--> $DIR/unsized-enum2.rs:57:15
= help: the trait `std::marker::Sized` is not implemented for `(dyn FooBar + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VO(isize, &dyn FooBar),
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VO(isize, Box<dyn FooBar>),
+ | ^^^^ ^
error[E0277]: the size for values of type `(dyn BarFoo + 'static)` cannot be known at compilation time
- --> $DIR/unsized-enum2.rs:59:18
+ --> $DIR/unsized-enum2.rs:59:21
|
LL | VP{u: isize, x: dyn BarFoo},
- | ^^^^^^^^^^^^^ doesn't have a size known at compile-time
+ | ^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `(dyn BarFoo + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VP{u: isize, x: &dyn BarFoo},
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VP{u: isize, x: Box<dyn BarFoo>},
+ | ^^^^ ^
error[E0277]: the size for values of type `[i8]` cannot be known at compilation time
--> $DIR/unsized-enum2.rs:63:8
= help: the trait `std::marker::Sized` is not implemented for `[i8]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VQ(&<&'static [i8] as Deref>::Target),
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VQ(Box<<&'static [i8] as Deref>::Target>),
+ | ^^^^ ^
error[E0277]: the size for values of type `[char]` cannot be known at compilation time
- --> $DIR/unsized-enum2.rs:65:8
+ --> $DIR/unsized-enum2.rs:65:11
|
LL | VR{x: <&'static [char] as Deref>::Target},
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `[char]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VR{x: &<&'static [char] as Deref>::Target},
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VR{x: Box<<&'static [char] as Deref>::Target>},
+ | ^^^^ ^
error[E0277]: the size for values of type `[f64]` cannot be known at compilation time
--> $DIR/unsized-enum2.rs:67:15
= help: the trait `std::marker::Sized` is not implemented for `[f64]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VS(isize, &<&'static [f64] as Deref>::Target),
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VS(isize, Box<<&'static [f64] as Deref>::Target>),
+ | ^^^^ ^
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
- --> $DIR/unsized-enum2.rs:69:18
+ --> $DIR/unsized-enum2.rs:69:21
|
LL | VT{u: isize, x: <&'static [i32] as Deref>::Target},
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `[i32]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VT{u: isize, x: &<&'static [i32] as Deref>::Target},
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VT{u: isize, x: Box<<&'static [i32] as Deref>::Target>},
+ | ^^^^ ^
error[E0277]: the size for values of type `(dyn PathHelper1 + 'static)` cannot be known at compilation time
--> $DIR/unsized-enum2.rs:43:8
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required because it appears within the type `Path1`
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VI(&Path1),
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VI(Box<Path1>),
+ | ^^^^ ^
error[E0277]: the size for values of type `(dyn PathHelper2 + 'static)` cannot be known at compilation time
- --> $DIR/unsized-enum2.rs:45:8
+ --> $DIR/unsized-enum2.rs:45:11
|
LL | VJ{x: Path2},
- | ^^^^^^^^ doesn't have a size known at compile-time
+ | ^^^^^ doesn't have a size known at compile-time
|
= help: within `Path2`, the trait `std::marker::Sized` is not implemented for `(dyn PathHelper2 + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required because it appears within the type `Path2`
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VJ{x: &Path2},
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VJ{x: Box<Path2>},
+ | ^^^^ ^
error[E0277]: the size for values of type `(dyn PathHelper3 + 'static)` cannot be known at compilation time
--> $DIR/unsized-enum2.rs:47:15
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required because it appears within the type `Path3`
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VK(isize, &Path3),
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VK(isize, Box<Path3>),
+ | ^^^^ ^
error[E0277]: the size for values of type `(dyn PathHelper4 + 'static)` cannot be known at compilation time
- --> $DIR/unsized-enum2.rs:49:18
+ --> $DIR/unsized-enum2.rs:49:21
|
LL | VL{u: isize, x: Path4},
- | ^^^^^^^^ doesn't have a size known at compile-time
+ | ^^^^^ doesn't have a size known at compile-time
|
= help: within `Path4`, the trait `std::marker::Sized` is not implemented for `(dyn PathHelper4 + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required because it appears within the type `Path4`
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | VL{u: isize, x: &Path4},
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | VL{u: isize, x: Box<Path4>},
+ | ^^^^ ^
error: aborting due to 20 previous errors
error[E0277]: the size for values of type `X` cannot be known at compilation time
- --> $DIR/unsized5.rs:4:5
+ --> $DIR/unsized5.rs:4:9
|
LL | struct S1<X: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
LL | f1: X,
- | ^^^^^ doesn't have a size known at compile-time
+ | ^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `X`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: only the last field of a struct may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | f1: &X,
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | f1: Box<X>,
+ | ^^^^ ^
error[E0277]: the size for values of type `X` cannot be known at compilation time
- --> $DIR/unsized5.rs:10:5
+ --> $DIR/unsized5.rs:10:8
|
LL | struct S2<X: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
LL | f: isize,
LL | g: X,
- | ^^^^ doesn't have a size known at compile-time
+ | ^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `X`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: only the last field of a struct may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | g: &X,
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | g: Box<X>,
+ | ^^^^ ^
error[E0277]: the size for values of type `str` cannot be known at compilation time
- --> $DIR/unsized5.rs:15:5
+ --> $DIR/unsized5.rs:15:8
|
LL | f: str,
- | ^^^^^^ doesn't have a size known at compile-time
+ | ^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `str`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: only the last field of a struct may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | f: &str,
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | f: Box<str>,
+ | ^^^^ ^
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
- --> $DIR/unsized5.rs:20:5
+ --> $DIR/unsized5.rs:20:8
|
LL | f: [u8],
- | ^^^^^^^ doesn't have a size known at compile-time
+ | ^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `[u8]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: only the last field of a struct may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | f: &[u8],
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | f: Box<[u8]>,
+ | ^^^^ ^
error[E0277]: the size for values of type `X` cannot be known at compilation time
--> $DIR/unsized5.rs:25:8
= help: the trait `std::marker::Sized` is not implemented for `X`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | V1(&X, isize),
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | V1(Box<X>, isize),
+ | ^^^^ ^
error[E0277]: the size for values of type `X` cannot be known at compilation time
- --> $DIR/unsized5.rs:29:8
+ --> $DIR/unsized5.rs:29:12
|
LL | enum F<X: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
LL | V2{f1: X, f: isize},
- | ^^^^^ doesn't have a size known at compile-time
+ | ^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `X`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: no field of an enum variant may have a dynamically sized type
+ = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+ |
+LL | V2{f1: &X, f: isize},
+ | ^
+help: heap allocated types always have a statically known size
+ |
+LL | V2{f1: Box<X>, f: isize},
+ | ^^^^ ^
error: aborting due to 6 previous errors
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
- --> $DIR/wf-array-elem-sized.rs:7:5
+ --> $DIR/wf-array-elem-sized.rs:7:10
|
LL | foo: [[u8]],
- | ^^^^^^^^^^^ doesn't have a size known at compile-time
+ | ^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `[u8]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
error[E0277]: the trait bound `A: std::marker::Copy` is not satisfied
- --> $DIR/wf-enum-fields-struct-variant.rs:13:9
+ --> $DIR/wf-enum-fields-struct-variant.rs:13:12
|
LL | struct IsCopy<T:Copy> {
| ---- required by this bound in `IsCopy`
...
LL | f: IsCopy<A>
- | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A`
+ | ^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A`
|
help: consider restricting type parameter `A`
|
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
- --> $DIR/wf-in-fn-type-arg.rs:9:5
+ --> $DIR/wf-in-fn-type-arg.rs:9:8
|
LL | struct MustBeCopy<T:Copy> {
| ---- required by this bound in `MustBeCopy`
...
LL | x: fn(MustBeCopy<T>)
- | ^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
+ | ^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
|
help: consider restricting type parameter `T`
|
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
- --> $DIR/wf-in-fn-type-ret.rs:9:5
+ --> $DIR/wf-in-fn-type-ret.rs:9:8
|
LL | struct MustBeCopy<T:Copy> {
| ---- required by this bound in `MustBeCopy`
...
LL | x: fn() -> MustBeCopy<T>
- | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
+ | ^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
|
help: consider restricting type parameter `T`
|
error[E0310]: the parameter type `T` may not live long enough
- --> $DIR/wf-in-fn-type-static.rs:13:5
+ --> $DIR/wf-in-fn-type-static.rs:13:8
|
LL | struct Foo<T> {
| - help: consider adding an explicit lifetime bound...: `T: 'static`
LL | // needs T: 'static
LL | x: fn() -> &'static T
- | ^^^^^^^^^^^^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at
+ | ^^^^^^^^^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at
error[E0310]: the parameter type `T` may not live long enough
- --> $DIR/wf-in-fn-type-static.rs:18:5
+ --> $DIR/wf-in-fn-type-static.rs:18:8
|
LL | struct Bar<T> {
| - help: consider adding an explicit lifetime bound...: `T: 'static`
LL | // needs T: Copy
LL | x: fn(&'static T)
- | ^^^^^^^^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at
+ | ^^^^^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at
error: aborting due to 2 previous errors
error[E0310]: the parameter type `T` may not live long enough
- --> $DIR/wf-in-obj-type-static.rs:14:5
+ --> $DIR/wf-in-obj-type-static.rs:14:8
|
LL | struct Foo<T> {
| - help: consider adding an explicit lifetime bound...: `T: 'static`
LL | // needs T: 'static
LL | x: dyn Object<&'static T>
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at
+ | ^^^^^^^^^^^^^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at
error: aborting due to previous error
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
- --> $DIR/wf-in-obj-type-trait.rs:11:5
+ --> $DIR/wf-in-obj-type-trait.rs:11:8
|
LL | struct MustBeCopy<T:Copy> {
| ---- required by this bound in `MustBeCopy`
...
LL | x: dyn Object<MustBeCopy<T>>
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
|
help: consider restricting type parameter `T`
|
error[E0277]: the trait bound `A: std::marker::Copy` is not satisfied
- --> $DIR/wf-struct-field.rs:12:5
+ --> $DIR/wf-struct-field.rs:12:11
|
LL | struct IsCopy<T:Copy> {
| ---- required by this bound in `IsCopy`
...
LL | data: IsCopy<A>
- | ^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A`
+ | ^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A`
|
help: consider restricting type parameter `A`
|