From 15a40c7ee85fff41f34a2b70c28cca3bcdec1015 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Fri, 23 Jul 2021 18:47:53 -0700 Subject: Do not discard `?Sized` type params and suggest their removal --- .../const-argument-if-length.full.stderr | 9 + .../const-argument-if-length.min.stderr | 4 + .../ui/dst/dst-object-from-unsized-type.stderr | 8 + src/test/ui/packed/issue-27060-2.stderr | 4 + .../adt-param-with-implicit-sized-bound.stderr | 4 + src/test/ui/trait-bounds/unsized-bound.rs | 32 +++ src/test/ui/trait-bounds/unsized-bound.stderr | 234 +++++++++++++++++++++ src/test/ui/traits/suggest-where-clause.stderr | 9 + src/test/ui/union/union-sized-field.stderr | 12 ++ src/test/ui/unsized/unsized-bare-typaram.stderr | 5 + src/test/ui/unsized/unsized-enum.stderr | 4 + src/test/ui/unsized/unsized-enum2.stderr | 16 ++ src/test/ui/unsized/unsized-fn-arg.fixed | 2 +- src/test/ui/unsized/unsized-fn-arg.stderr | 4 + .../unsized/unsized-inherent-impl-self-type.stderr | 4 + src/test/ui/unsized/unsized-struct.stderr | 8 + .../ui/unsized/unsized-trait-impl-self-type.stderr | 4 + .../ui/unsized/unsized-trait-impl-trait-arg.stderr | 4 + src/test/ui/unsized/unsized3.stderr | 24 +++ src/test/ui/unsized/unsized5.stderr | 16 ++ src/test/ui/unsized/unsized6.stderr | 52 +++++ src/test/ui/unsized/unsized7.stderr | 4 + 22 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/trait-bounds/unsized-bound.rs create mode 100644 src/test/ui/trait-bounds/unsized-bound.stderr (limited to 'src/test') diff --git a/src/test/ui/const-generics/const-argument-if-length.full.stderr b/src/test/ui/const-generics/const-argument-if-length.full.stderr index c6088e665a2..a9f1d0eb657 100644 --- a/src/test/ui/const-generics/const-argument-if-length.full.stderr +++ b/src/test/ui/const-generics/const-argument-if-length.full.stderr @@ -10,6 +10,11 @@ LL | if std::mem::size_of::() == 0 { | LL | pub const fn size_of() -> usize { | - required by this bound in `std::mem::size_of` + | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | pub const fn is_zst() -> usize { + | -- error[E0277]: the size for values of type `T` cannot be known at compilation time --> $DIR/const-argument-if-length.rs:16:12 @@ -21,6 +26,10 @@ LL | value: T, | = 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: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | pub struct AtLeastByte { + | -- help: borrowed types always have a statically known size | LL | value: &T, diff --git a/src/test/ui/const-generics/const-argument-if-length.min.stderr b/src/test/ui/const-generics/const-argument-if-length.min.stderr index bc06e8d7fb1..173a1471663 100644 --- a/src/test/ui/const-generics/const-argument-if-length.min.stderr +++ b/src/test/ui/const-generics/const-argument-if-length.min.stderr @@ -17,6 +17,10 @@ LL | value: T, | = 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: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | pub struct AtLeastByte { + | -- help: borrowed types always have a statically known size | LL | value: &T, diff --git a/src/test/ui/dst/dst-object-from-unsized-type.stderr b/src/test/ui/dst/dst-object-from-unsized-type.stderr index 2d12265df98..6c57dd9316f 100644 --- a/src/test/ui/dst/dst-object-from-unsized-type.stderr +++ b/src/test/ui/dst/dst-object-from-unsized-type.stderr @@ -7,6 +7,10 @@ LL | let u: &dyn Foo = t; | ^ doesn't have a size known at compile-time | = note: required for the cast to the object type `dyn Foo` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn test1(t: &T) { + | -- error[E0277]: the size for values of type `T` cannot be known at compilation time --> $DIR/dst-object-from-unsized-type.rs:13:23 @@ -17,6 +21,10 @@ LL | let v: &dyn Foo = t as &dyn Foo; | ^ doesn't have a size known at compile-time | = note: required for the cast to the object type `dyn Foo` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn test2(t: &T) { + | -- error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/dst-object-from-unsized-type.rs:18:28 diff --git a/src/test/ui/packed/issue-27060-2.stderr b/src/test/ui/packed/issue-27060-2.stderr index 5dbcc96e874..64e061a89b4 100644 --- a/src/test/ui/packed/issue-27060-2.stderr +++ b/src/test/ui/packed/issue-27060-2.stderr @@ -8,6 +8,10 @@ LL | data: T, | = 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: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | pub struct Bad { + | -- help: borrowed types always have a statically known size | LL | data: &T, diff --git a/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr b/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr index 18ba7254446..ac3902dc6de 100644 --- a/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr +++ b/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr @@ -91,6 +91,10 @@ LL | struct X(T); | ^ - ...if indirection were used here: `Box` | | | this could be changed to `T: ?Sized`... +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | struct Struct5{ + | -- error: aborting due to 5 previous errors diff --git a/src/test/ui/trait-bounds/unsized-bound.rs b/src/test/ui/trait-bounds/unsized-bound.rs new file mode 100644 index 00000000000..035b8ef1bde --- /dev/null +++ b/src/test/ui/trait-bounds/unsized-bound.rs @@ -0,0 +1,32 @@ +trait Trait {} +impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} +//~^ ERROR E0277 +//~| ERROR E0277 +impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} +//~^ ERROR E0277 +//~| ERROR E0277 +//~| ERROR E0277 +trait Trait2 {} +impl Trait2<(A, B)> for (A, B) {} +//~^ ERROR E0277 +//~| ERROR E0277 +trait Trait3 {} +impl Trait3 for A where A: ?Sized {} +//~^ ERROR E0277 +trait Trait4 {} +impl Trait4 for A {} +//~^ ERROR E0277 +trait Trait5 {} +impl Trait5 for X where X: ?Sized {} +//~^ ERROR E0277 +trait Trait6 {} +impl Trait6 for X {} +//~^ ERROR E0277 +trait Trait7 {} +impl Trait7 for X where Y: ?Sized {} +//~^ ERROR E0277 +trait Trait8 {} +impl Trait8 for X {} +//~^ ERROR E0277 + +fn main() {} diff --git a/src/test/ui/trait-bounds/unsized-bound.stderr b/src/test/ui/trait-bounds/unsized-bound.stderr new file mode 100644 index 00000000000..30163ab7978 --- /dev/null +++ b/src/test/ui/trait-bounds/unsized-bound.stderr @@ -0,0 +1,234 @@ +error[E0277]: the size for values of type `B` cannot be known at compilation time + --> $DIR/unsized-bound.rs:2:12 + | +LL | trait Trait {} + | - required by this bound in `Trait` +LL | impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} + | - ^^^^^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | + = note: required because it appears within the type `(A, B)` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl Trait<(A, B)> for (A, B) where A: ?Sized, {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `A` cannot be known at compilation time + --> $DIR/unsized-bound.rs:2:30 + | +LL | impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} + | - ^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | + = note: only the last element of a tuple may have a dynamically sized type +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl Trait<(A, B)> for (A, B) where B: ?Sized, {} + | -- + +error[E0277]: the size for values of type `C` cannot be known at compilation time + --> $DIR/unsized-bound.rs:5:31 + | +LL | trait Trait {} + | - required by this bound in `Trait` +... +LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} + | - ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | + = note: required because it appears within the type `(A, B, C)` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `A` cannot be known at compilation time + --> $DIR/unsized-bound.rs:5:52 + | +LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} + | - ^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | + = note: only the last element of a tuple may have a dynamically sized type +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl Trait<(A, B, C)> for (A, B, C) {} + | -- + +error[E0277]: the size for values of type `B` cannot be known at compilation time + --> $DIR/unsized-bound.rs:5:52 + | +LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} + | - ^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | + = note: only the last element of a tuple may have a dynamically sized type +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} + | -- + +error[E0277]: the size for values of type `B` cannot be known at compilation time + --> $DIR/unsized-bound.rs:10:28 + | +LL | trait Trait2 {} + | - required by this bound in `Trait2` +LL | impl Trait2<(A, B)> for (A, B) {} + | - ^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | + = note: required because it appears within the type `(A, B)` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl Trait2<(A, B)> for (A, B) {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait2 {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `A` cannot be known at compilation time + --> $DIR/unsized-bound.rs:10:47 + | +LL | impl Trait2<(A, B)> for (A, B) {} + | - ^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | + = note: only the last element of a tuple may have a dynamically sized type +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl Trait2<(A, B)> for (A, B) {} + | -- + +error[E0277]: the size for values of type `A` cannot be known at compilation time + --> $DIR/unsized-bound.rs:14:9 + | +LL | trait Trait3 {} + | - required by this bound in `Trait3` +LL | impl Trait3 for A where A: ?Sized {} + | - ^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl Trait3 for A {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait3 {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `A` cannot be known at compilation time + --> $DIR/unsized-bound.rs:17:17 + | +LL | trait Trait4 {} + | - required by this bound in `Trait4` +LL | impl Trait4 for A {} + | - ^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl Trait4 for A {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait4 {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized-bound.rs:20:12 + | +LL | trait Trait5 {} + | - required by this bound in `Trait5` +LL | impl Trait5 for X where X: ?Sized {} + | - ^^^^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl Trait5 for X {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait5 {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized-bound.rs:23:20 + | +LL | trait Trait6 {} + | - required by this bound in `Trait6` +LL | impl Trait6 for X {} + | - ^^^^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl Trait6 for X {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait6 {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `Y` cannot be known at compilation time + --> $DIR/unsized-bound.rs:26:12 + | +LL | trait Trait7 {} + | - required by this bound in `Trait7` +LL | impl Trait7 for X where Y: ?Sized {} + | - ^^^^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl Trait7 for X {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait7 {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `Y` cannot be known at compilation time + --> $DIR/unsized-bound.rs:29:20 + | +LL | trait Trait8 {} + | - required by this bound in `Trait8` +LL | impl Trait8 for X {} + | - ^^^^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl Trait8 for X {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait8 {} + | ^^^^^^^^ + +error: aborting due to 13 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/traits/suggest-where-clause.stderr b/src/test/ui/traits/suggest-where-clause.stderr index f15e7e35839..47f287807d4 100644 --- a/src/test/ui/traits/suggest-where-clause.stderr +++ b/src/test/ui/traits/suggest-where-clause.stderr @@ -11,6 +11,11 @@ LL | mem::size_of::(); | LL | pub const fn size_of() -> usize { | - required by this bound in `std::mem::size_of` + | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn check() { + | -- error[E0277]: the size for values of type `U` cannot be known at compilation time --> $DIR/suggest-where-clause.rs:10:5 @@ -31,6 +36,10 @@ note: required because it appears within the type `Misc` | LL | struct Misc(T); | ^^^^ +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn check() { + | -- error[E0277]: the trait bound `u64: From` is not satisfied --> $DIR/suggest-where-clause.rs:15:5 diff --git a/src/test/ui/union/union-sized-field.stderr b/src/test/ui/union/union-sized-field.stderr index b916bbe8ad1..ef86c624e9b 100644 --- a/src/test/ui/union/union-sized-field.stderr +++ b/src/test/ui/union/union-sized-field.stderr @@ -8,6 +8,10 @@ LL | value: T, | = 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: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | union Foo { + | -- help: borrowed types always have a statically known size | LL | value: &T, @@ -27,6 +31,10 @@ LL | value: T, | = 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: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | struct Foo2 { + | -- help: borrowed types always have a statically known size | LL | value: &T, @@ -46,6 +54,10 @@ LL | Value(T), | = 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: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | enum Foo3 { + | -- help: borrowed types always have a statically known size | LL | Value(&T), diff --git a/src/test/ui/unsized/unsized-bare-typaram.stderr b/src/test/ui/unsized/unsized-bare-typaram.stderr index 19978ae24ca..35bba1c103a 100644 --- a/src/test/ui/unsized/unsized-bare-typaram.stderr +++ b/src/test/ui/unsized/unsized-bare-typaram.stderr @@ -7,6 +7,11 @@ LL | fn foo() { bar::() } | - ^ doesn't have a size known at compile-time | | | this type parameter needs to be `std::marker::Sized` + | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn foo() { bar::() } + | -- error: aborting due to previous error diff --git a/src/test/ui/unsized/unsized-enum.stderr b/src/test/ui/unsized/unsized-enum.stderr index 601db7d1cd9..f66ce2af304 100644 --- a/src/test/ui/unsized/unsized-enum.stderr +++ b/src/test/ui/unsized/unsized-enum.stderr @@ -16,6 +16,10 @@ LL | enum Foo { FooSome(U), FooNone } | ^ - ...if indirection were used here: `Box` | | | this could be changed to `U: ?Sized`... +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn foo2() { not_sized::>() } + | -- error: aborting due to previous error diff --git a/src/test/ui/unsized/unsized-enum2.stderr b/src/test/ui/unsized/unsized-enum2.stderr index 1b6c8585815..b9a03d904af 100644 --- a/src/test/ui/unsized/unsized-enum2.stderr +++ b/src/test/ui/unsized/unsized-enum2.stderr @@ -9,6 +9,10 @@ LL | VA(W), | = 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: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | enum E { + | -- help: borrowed types always have a statically known size | LL | VA(&W), @@ -29,6 +33,10 @@ LL | VB{x: X}, | = 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: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | enum E { + | -- help: borrowed types always have a statically known size | LL | VB{x: &X}, @@ -49,6 +57,10 @@ LL | VC(isize, Y), | = 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: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | enum E { + | -- help: borrowed types always have a statically known size | LL | VC(isize, &Y), @@ -69,6 +81,10 @@ LL | VD{u: isize, x: Z}, | = 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: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | enum E { + | -- help: borrowed types always have a statically known size | LL | VD{u: isize, x: &Z}, diff --git a/src/test/ui/unsized/unsized-fn-arg.fixed b/src/test/ui/unsized/unsized-fn-arg.fixed index 2c686c6c2b2..fd9b159a481 100644 --- a/src/test/ui/unsized/unsized-fn-arg.fixed +++ b/src/test/ui/unsized/unsized-fn-arg.fixed @@ -2,5 +2,5 @@ #![crate_type="lib"] #![allow(unused)] -fn f(t: &T) {} +fn f(t: &T) {} //~^ ERROR the size for values of type `T` cannot be known at compilation time diff --git a/src/test/ui/unsized/unsized-fn-arg.stderr b/src/test/ui/unsized/unsized-fn-arg.stderr index 6b802ddf542..acb8a598d2c 100644 --- a/src/test/ui/unsized/unsized-fn-arg.stderr +++ b/src/test/ui/unsized/unsized-fn-arg.stderr @@ -7,6 +7,10 @@ LL | fn f(t: T) {} | this type parameter needs to be `std::marker::Sized` | = help: unsized fn params are gated as an unstable feature +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f(t: T) {} + | -- help: function arguments must have a statically known size, borrowed types always have a known size | LL | fn f(t: &T) {} diff --git a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr index 9d072eda4e8..99f75d8c5b3 100644 --- a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr @@ -16,6 +16,10 @@ LL | struct S5(Y); | ^ - ...if indirection were used here: `Box` | | | this could be changed to `Y: ?Sized`... +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl S5 { + | -- error: aborting due to previous error diff --git a/src/test/ui/unsized/unsized-struct.stderr b/src/test/ui/unsized/unsized-struct.stderr index e38375bff46..71693b8130d 100644 --- a/src/test/ui/unsized/unsized-struct.stderr +++ b/src/test/ui/unsized/unsized-struct.stderr @@ -16,6 +16,10 @@ LL | struct Foo { data: T } | ^ - ...if indirection were used here: `Box` | | | this could be changed to `T: ?Sized`... +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn foo2() { not_sized::>() } + | -- error[E0277]: the size for values of type `T` cannot be known at compilation time --> $DIR/unsized-struct.rs:13:24 @@ -33,6 +37,10 @@ note: required because it appears within the type `Bar` | LL | struct Bar { data: T } | ^^^ +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn bar2() { is_sized::>() } + | -- error: aborting due to 2 previous errors diff --git a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr index aef0d0cbb83..201dbf85d20 100644 --- a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr @@ -16,6 +16,10 @@ LL | struct S5(Y); | ^ - ...if indirection were used here: `Box` | | | this could be changed to `Y: ?Sized`... +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl T3 for S5 { + | -- error: aborting due to previous error diff --git a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr index f48d4ef9f14..f8f8aa8e3e9 100644 --- a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr @@ -9,6 +9,10 @@ LL | impl T2 for S4 { | | | this type parameter needs to be `std::marker::Sized` | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl T2 for S4 { + | -- help: consider relaxing the implicit `Sized` restriction | LL | trait T2 { diff --git a/src/test/ui/unsized/unsized3.stderr b/src/test/ui/unsized/unsized3.stderr index bd36008aca0..10ddfe34eac 100644 --- a/src/test/ui/unsized/unsized3.stderr +++ b/src/test/ui/unsized/unsized3.stderr @@ -9,6 +9,10 @@ LL | f2::(x); LL | fn f2(x: &X) { | - required by this bound in `f2` | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f1(x: &X) { + | -- help: consider relaxing the implicit `Sized` restriction | LL | fn f2(x: &X) { @@ -25,6 +29,10 @@ LL | f4::(x); LL | fn f4(x: &X) { | - required by this bound in `f4` | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f3(x: &X) { + | -- help: consider relaxing the implicit `Sized` restriction | LL | fn f4(x: &X) { @@ -46,6 +54,10 @@ note: required because it appears within the type `S` | LL | struct S { | ^ +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f8(x1: &S, x2: &S) { + | -- help: consider relaxing the implicit `Sized` restriction | LL | fn f5(x: &Y) {} @@ -65,6 +77,10 @@ note: required because it appears within the type `S` LL | struct S { | ^ = note: only the last element of a tuple may have a dynamically sized type +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f9(x1: Box>) { + | -- error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized3.rs:45:9 @@ -81,6 +97,10 @@ LL | struct S { | ^ = note: required because it appears within the type `({integer}, S)` = note: tuples must have a statically known size to be initialized +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f10(x1: Box>) { + | -- error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized3.rs:45:8 @@ -99,6 +119,10 @@ note: required because it appears within the type `S` LL | struct S { | ^ = note: required because it appears within the type `({integer}, S)` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f10(x1: Box>) { + | -- help: consider relaxing the implicit `Sized` restriction | LL | fn f5(x: &Y) {} diff --git a/src/test/ui/unsized/unsized5.stderr b/src/test/ui/unsized/unsized5.stderr index 0bfd4565529..6e5b3556429 100644 --- a/src/test/ui/unsized/unsized5.stderr +++ b/src/test/ui/unsized/unsized5.stderr @@ -8,6 +8,10 @@ LL | f1: X, | = 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: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | struct S1 { + | -- help: borrowed types always have a statically known size | LL | f1: &X, @@ -28,6 +32,10 @@ LL | g: X, | = 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: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | struct S2 { + | -- help: borrowed types always have a statically known size | LL | g: &X, @@ -83,6 +91,10 @@ LL | V1(X, isize), | = 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: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | enum E { + | -- help: borrowed types always have a statically known size | LL | V1(&X, isize), @@ -102,6 +114,10 @@ LL | V2{f1: X, f: isize}, | = 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: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | enum F { + | -- help: borrowed types always have a statically known size | LL | V2{f1: &X, f: isize}, diff --git a/src/test/ui/unsized/unsized6.stderr b/src/test/ui/unsized/unsized6.stderr index 8e5734dffb1..5eff89d971f 100644 --- a/src/test/ui/unsized/unsized6.stderr +++ b/src/test/ui/unsized/unsized6.stderr @@ -9,6 +9,10 @@ LL | let y: Y; | = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f1(x: &X) { + | -- error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:7:12 @@ -20,6 +24,10 @@ LL | let _: (isize, (X, isize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = note: only the last element of a tuple may have a dynamically sized type +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f1(x: &X) { + | -- error[E0277]: the size for values of type `Z` cannot be known at compilation time --> $DIR/unsized6.rs:11:12 @@ -31,6 +39,10 @@ LL | let y: (isize, (Z, usize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = note: only the last element of a tuple may have a dynamically sized type +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f1(x: &X) { + | -- error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:15:9 @@ -42,6 +54,10 @@ LL | let y: X; | = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f2(x: &X) { + | -- error[E0277]: the size for values of type `Y` cannot be known at compilation time --> $DIR/unsized6.rs:17:12 @@ -53,6 +69,10 @@ LL | let y: (isize, (Y, isize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = note: only the last element of a tuple may have a dynamically sized type +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f2(x: &X) { + | -- error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:22:9 @@ -64,6 +84,10 @@ LL | let y: X = *x1; | = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f3(x1: Box, x2: Box, x3: Box) { + | -- error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:24:9 @@ -76,6 +100,10 @@ LL | let y = *x2; | = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f3(x1: Box, x2: Box, x3: Box) { + | -- error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:26:10 @@ -88,6 +116,10 @@ LL | let (y, z) = (*x3, 4); | = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f3(x1: Box, x2: Box, x3: Box) { + | -- error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:30:9 @@ -99,6 +131,10 @@ LL | let y: X = *x1; | = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f4(x1: Box, x2: Box, x3: Box) { + | -- error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:32:9 @@ -111,6 +147,10 @@ LL | let y = *x2; | = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f4(x1: Box, x2: Box, x3: Box) { + | -- error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:34:10 @@ -123,6 +163,10 @@ LL | let (y, z) = (*x3, 4); | = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f4(x1: Box, x2: Box, x3: Box) { + | -- error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:38:18 @@ -133,6 +177,10 @@ LL | fn g1(x: X) {} | this type parameter needs to be `std::marker::Sized` | = help: unsized fn params are gated as an unstable feature +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn g1(x: X) {} + | -- help: function arguments must have a statically known size, borrowed types always have a known size | LL | fn g1(x: &X) {} @@ -147,6 +195,10 @@ LL | fn g2(x: X) {} | this type parameter needs to be `std::marker::Sized` | = help: unsized fn params are gated as an unstable feature +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn g2(x: X) {} + | -- help: function arguments must have a statically known size, borrowed types always have a known size | LL | fn g2(x: &X) {} diff --git a/src/test/ui/unsized/unsized7.stderr b/src/test/ui/unsized/unsized7.stderr index 7dbddd4ed24..e0d95e21296 100644 --- a/src/test/ui/unsized/unsized7.stderr +++ b/src/test/ui/unsized/unsized7.stderr @@ -9,6 +9,10 @@ LL | impl T1 for S3 { | | | this type parameter needs to be `std::marker::Sized` | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl T1 for S3 { + | -- help: consider relaxing the implicit `Sized` restriction | LL | trait T1 { -- cgit 1.4.1-3-g733a5