diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2021-07-23 18:47:53 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2021-07-30 08:44:31 -0700 |
| commit | 15a40c7ee85fff41f34a2b70c28cca3bcdec1015 (patch) | |
| tree | 1a732d38fc28716a9f4c3a6eb72ae2f5badd0300 /src/test | |
| parent | 5fb3394cbdf0622c9d0c292feb55db0f4c828dc3 (diff) | |
| download | rust-15a40c7ee85fff41f34a2b70c28cca3bcdec1015.tar.gz rust-15a40c7ee85fff41f34a2b70c28cca3bcdec1015.zip | |
Do not discard `?Sized` type params and suggest their removal
Diffstat (limited to 'src/test')
22 files changed, 462 insertions, 1 deletions
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::<T>() == 0 { | LL | pub const fn size_of<T>() -> 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<T>() -> 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<T> { + | -- 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<T> { + | -- 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: Foo>(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: Foo>(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<T> { + | -- 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>(T); | ^ - ...if indirection were used here: `Box<T>` | | | this could be changed to `T: ?Sized`... +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | struct Struct5<T>{ + | -- 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<A> {} +impl<A, B> Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} +//~^ ERROR E0277 +//~| ERROR E0277 +impl<A, B: ?Sized, C: ?Sized> Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} +//~^ ERROR E0277 +//~| ERROR E0277 +//~| ERROR E0277 +trait Trait2<A> {} +impl<A: ?Sized, B: ?Sized> Trait2<(A, B)> for (A, B) {} +//~^ ERROR E0277 +//~| ERROR E0277 +trait Trait3<A> {} +impl<A> Trait3<A> for A where A: ?Sized {} +//~^ ERROR E0277 +trait Trait4<A> {} +impl<A: ?Sized> Trait4<A> for A {} +//~^ ERROR E0277 +trait Trait5<A, B> {} +impl<X, Y> Trait5<X, Y> for X where X: ?Sized {} +//~^ ERROR E0277 +trait Trait6<A, B> {} +impl<X: ?Sized, Y> Trait6<X, Y> for X {} +//~^ ERROR E0277 +trait Trait7<A, B> {} +impl<X, Y> Trait7<X, Y> for X where Y: ?Sized {} +//~^ ERROR E0277 +trait Trait8<A, B> {} +impl<X, Y: ?Sized> Trait8<X, Y> 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<A> {} + | - required by this bound in `Trait` +LL | impl<A, B> 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<A, B> Trait<(A, B)> for (A, B) where A: ?Sized, {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait<A: ?Sized> {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `A` cannot be known at compilation time + --> $DIR/unsized-bound.rs:2:30 + | +LL | impl<A, B> 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<A, B> 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<A> {} + | - required by this bound in `Trait` +... +LL | impl<A, B: ?Sized, C: ?Sized> 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<A, B: ?Sized, C> Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait<A: ?Sized> {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `A` cannot be known at compilation time + --> $DIR/unsized-bound.rs:5:52 + | +LL | impl<A, B: ?Sized, C: ?Sized> 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<A, B: ?Sized, C: ?Sized> 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<A, B: ?Sized, C: ?Sized> 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<A, B, C: ?Sized> 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<A> {} + | - required by this bound in `Trait2` +LL | impl<A: ?Sized, B: ?Sized> 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<A: ?Sized, B> Trait2<(A, B)> for (A, B) {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait2<A: ?Sized> {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `A` cannot be known at compilation time + --> $DIR/unsized-bound.rs:10:47 + | +LL | impl<A: ?Sized, B: ?Sized> 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<A, B: ?Sized> 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<A> {} + | - required by this bound in `Trait3` +LL | impl<A> Trait3<A> 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<A> Trait3<A> for A {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait3<A: ?Sized> {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `A` cannot be known at compilation time + --> $DIR/unsized-bound.rs:17:17 + | +LL | trait Trait4<A> {} + | - required by this bound in `Trait4` +LL | impl<A: ?Sized> Trait4<A> 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<A> Trait4<A> for A {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait4<A: ?Sized> {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized-bound.rs:20:12 + | +LL | trait Trait5<A, B> {} + | - required by this bound in `Trait5` +LL | impl<X, Y> Trait5<X, Y> 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<X, Y> Trait5<X, Y> for X {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait5<A: ?Sized, B> {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized-bound.rs:23:20 + | +LL | trait Trait6<A, B> {} + | - required by this bound in `Trait6` +LL | impl<X: ?Sized, Y> Trait6<X, Y> 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<X, Y> Trait6<X, Y> for X {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait6<A: ?Sized, B> {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `Y` cannot be known at compilation time + --> $DIR/unsized-bound.rs:26:12 + | +LL | trait Trait7<A, B> {} + | - required by this bound in `Trait7` +LL | impl<X, Y> Trait7<X, Y> 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<X, Y> Trait7<X, Y> for X {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait7<A, B: ?Sized> {} + | ^^^^^^^^ + +error[E0277]: the size for values of type `Y` cannot be known at compilation time + --> $DIR/unsized-bound.rs:29:20 + | +LL | trait Trait8<A, B> {} + | - required by this bound in `Trait8` +LL | impl<X, Y: ?Sized> Trait8<X, Y> 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<X, Y> Trait8<X, Y> for X {} + | -- +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait8<A, B: ?Sized> {} + | ^^^^^^^^ + +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::<U>(); | LL | pub const fn size_of<T>() -> 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<T: Iterator, U>() { + | -- 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<U>` | LL | struct Misc<T:?Sized>(T); | ^^^^ +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn check<T: Iterator, U>() { + | -- error[E0277]: the trait bound `u64: From<T>` 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<T> { + | -- 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<T> { + | -- 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<T> { + | -- 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<T: ?Sized>() { bar::<T>() } | - ^ 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<T>() { bar::<T>() } + | -- 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<U> { FooSome(U), FooNone } | ^ - ...if indirection were used here: `Box<U>` | | | this could be changed to `U: ?Sized`... +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn foo2<T>() { not_sized::<Foo<T>>() } + | -- 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<W, X: ?Sized, Y: ?Sized, Z: ?Sized> { + | -- 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<W: ?Sized, X, Y: ?Sized, Z: ?Sized> { + | -- 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<W: ?Sized, X: ?Sized, Y, Z: ?Sized> { + | -- 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<W: ?Sized, X: ?Sized, Y: ?Sized, Z> { + | -- 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: ?Sized>(t: &T) {} +fn f<T>(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: ?Sized>(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: T) {} + | -- help: function arguments must have a statically known size, borrowed types always have a known size | LL | fn f<T: ?Sized>(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>(Y); | ^ - ...if indirection were used here: `Box<Y>` | | | this could be changed to `Y: ?Sized`... +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl<X> S5<X> { + | -- 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<T> { data: T } | ^ - ...if indirection were used here: `Box<T>` | | | this could be changed to `T: ?Sized`... +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn foo2<T>() { not_sized::<Foo<T>>() } + | -- 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<T>` | LL | struct Bar<T: ?Sized> { data: T } | ^^^ +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn bar2<T>() { is_sized::<Bar<T>>() } + | -- 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>(Y); | ^ - ...if indirection were used here: `Box<Y>` | | | this could be changed to `Y: ?Sized`... +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl<X> T3<X> for S5<X> { + | -- 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<X: ?Sized> T2<X> for S4<X> { | | | this type parameter needs to be `std::marker::Sized` | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl<X> T2<X> for S4<X> { + | -- help: consider relaxing the implicit `Sized` restriction | LL | trait T2<Z: ?Sized> { 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>(x); LL | fn f2<X>(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: &X) { + | -- help: consider relaxing the implicit `Sized` restriction | LL | fn f2<X: ?Sized>(x: &X) { @@ -25,6 +29,10 @@ LL | f4::<X>(x); LL | fn f4<X: T>(x: &X) { | - required by this bound in `f4` | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f3<X: T>(x: &X) { + | -- help: consider relaxing the implicit `Sized` restriction | LL | fn f4<X: T + ?Sized>(x: &X) { @@ -46,6 +54,10 @@ note: required because it appears within the type `S<X>` | LL | struct S<X: ?Sized> { | ^ +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f8<X>(x1: &S<X>, x2: &S<X>) { + | -- help: consider relaxing the implicit `Sized` restriction | LL | fn f5<Y: ?Sized>(x: &Y) {} @@ -65,6 +77,10 @@ note: required because it appears within the type `S<X>` LL | struct S<X: ?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 | fn f9<X>(x1: Box<S<X>>) { + | -- 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<X: ?Sized> { | ^ = note: required because it appears within the type `({integer}, S<X>)` = 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<X>(x1: Box<S<X>>) { + | -- 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<X>` LL | struct S<X: ?Sized> { | ^ = note: required because it appears within the type `({integer}, S<X>)` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | fn f10<X>(x1: Box<S<X>>) { + | -- help: consider relaxing the implicit `Sized` restriction | LL | fn f5<Y: ?Sized>(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<X> { + | -- 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<X> { + | -- 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<X> { + | -- 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<X> { + | -- 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<W: ?Sized, X: ?Sized, Y, Z: ?Sized>(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<W: ?Sized, X, Y: ?Sized, Z: ?Sized>(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<W: ?Sized, X: ?Sized, Y: ?Sized, Z>(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, Y: ?Sized>(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: ?Sized, Y>(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<X>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { + | -- 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<X>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { + | -- 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<X>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { + | -- 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<X: T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { + | -- 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<X: T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { + | -- 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<X: T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { + | -- 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: ?Sized>(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: X) {} + | -- help: function arguments must have a statically known size, borrowed types always have a known size | LL | fn g1<X: ?Sized>(x: &X) {} @@ -147,6 +195,10 @@ LL | fn g2<X: ?Sized + T>(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: T>(x: X) {} + | -- help: function arguments must have a statically known size, borrowed types always have a known size | LL | fn g2<X: ?Sized + T>(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<X: ?Sized + T> T1<X> for S3<X> { | | | this type parameter needs to be `std::marker::Sized` | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL | impl<X: T> T1<X> for S3<X> { + | -- help: consider relaxing the implicit `Sized` restriction | LL | trait T1<Z: T + ?Sized> { |
