Suggest boxing or borrowing unsized fields
This commit is contained in:
parent
a15bda4036
commit
28e6f1f5b9
@ -229,6 +229,7 @@ pub enum ObligationCauseCode<'tcx> {
|
||||
/// 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,
|
||||
},
|
||||
|
||||
|
@ -156,7 +156,9 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
|
||||
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),
|
||||
|
@ -1856,7 +1856,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
ObligationCauseCode::StructInitializerSized => {
|
||||
err.note("structs must have a statically known size to be initialized");
|
||||
}
|
||||
ObligationCauseCode::FieldSized { adt_kind: ref item, last } => match *item {
|
||||
ObligationCauseCode::FieldSized { adt_kind: ref item, last, span } => {
|
||||
match *item {
|
||||
AdtKind::Struct => {
|
||||
if last {
|
||||
err.note(
|
||||
@ -1875,7 +1876,23 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
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");
|
||||
}
|
||||
|
@ -394,6 +394,7 @@ fn check_type_defn<'tcx, F>(
|
||||
Some(i) => i,
|
||||
None => bug!(),
|
||||
},
|
||||
span: field.span,
|
||||
last,
|
||||
},
|
||||
),
|
||||
@ -1329,7 +1330,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
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 }
|
||||
|
@ -16,10 +16,10 @@ LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
||||
= 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
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
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
|
||||
|
@ -1,10 +1,10 @@
|
||||
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
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
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...
|
||||
@ -7,7 +7,7 @@ LL | fn qiz();
|
||||
| --- ...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
|
||||
|
|
||||
|
@ -1,8 +1,8 @@
|
||||
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>
|
||||
|
@ -1,14 +1,23 @@
|
||||
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
|
||||
|
||||
|
@ -7,6 +7,15 @@ LL | V([Box<E>]),
|
||||
= 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
|
||||
|
||||
|
@ -8,10 +8,10 @@ LL | #![feature(lazy_normalization_consts)]
|
||||
= 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
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
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
|
||||
|
@ -5,10 +5,10 @@ LL | z: Box<dyn Is<'a>+'b+'c>,
|
||||
| ^^
|
||||
|
||||
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
|
||||
|
@ -1,8 +1,8 @@
|
||||
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
|
||||
|
@ -1,10 +1,10 @@
|
||||
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
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
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`
|
||||
@ -7,7 +7,7 @@ LL | struct X<T>(T);
|
||||
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>
|
||||
|
@ -13,13 +13,13 @@ LL | impl<T: Trait> Foo<T> {
|
||||
| ^^^^^^^
|
||||
|
||||
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
|
||||
@ -31,13 +31,13 @@ LL | Quux(Bar<usize>),
|
||||
| ^^^^^^^^^^ 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`
|
||||
|
|
||||
@ -68,13 +68,13 @@ LL | Foo<i32>,
|
||||
| ^^^^^^^^ 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
|
||||
|
||||
|
@ -1,26 +1,44 @@
|
||||
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
|
||||
@ -33,6 +51,15 @@ LL | Value(T),
|
||||
= 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
|
||||
|
||||
|
@ -1,22 +1,40 @@
|
||||
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
|
||||
|
||||
|
@ -10,19 +10,37 @@ LL | VA(W),
|
||||
= 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
|
||||
@ -36,19 +54,37 @@ LL | VC(isize, Y),
|
||||
= 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
|
||||
@ -59,16 +95,34 @@ LL | VE([u8]),
|
||||
= 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
|
||||
@ -79,16 +133,34 @@ LL | VG(isize, [f32]),
|
||||
= 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
|
||||
@ -99,16 +171,34 @@ LL | VM(dyn Foo),
|
||||
= 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
|
||||
@ -119,16 +209,34 @@ LL | VO(isize, dyn FooBar),
|
||||
= 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
|
||||
@ -139,16 +247,34 @@ LL | VQ(<&'static [i8] as Deref>::Target),
|
||||
= 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
|
||||
@ -159,16 +285,34 @@ LL | VS(isize, <&'static [f64] as Deref>::Target),
|
||||
= 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
|
||||
@ -180,17 +324,35 @@ LL | VI(Path1),
|
||||
= 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
|
||||
@ -202,17 +364,35 @@ LL | VK(isize, Path3),
|
||||
= 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
|
||||
|
||||
|
@ -1,47 +1,83 @@
|
||||
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
|
||||
@ -54,18 +90,36 @@ LL | V1(X, isize),
|
||||
= 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
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
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>
|
||||
|
@ -1,11 +1,11 @@
|
||||
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`
|
||||
|
|
||||
|
@ -1,11 +1,11 @@
|
||||
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`
|
||||
|
|
||||
|
@ -1,11 +1,11 @@
|
||||
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`
|
||||
|
|
||||
|
@ -1,20 +1,20 @@
|
||||
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
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
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
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
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`
|
||||
|
|
||||
|
@ -1,11 +1,11 @@
|
||||
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`
|
||||
|
|
||||
|
Loading…
x
Reference in New Issue
Block a user