Skip to content

Commit

Permalink
change std::marker::Sized to just Sized
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Markeffsky committed Jun 15, 2023
1 parent ee7e717 commit b6a3f12
Show file tree
Hide file tree
Showing 25 changed files with 69 additions and 76 deletions.
7 changes: 2 additions & 5 deletions compiler/rustc_middle/src/ty/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,10 @@ pub fn suggest_constraining_type_params<'a>(
{
let mut sized_constraints =
constraints.extract_if(|(_, def_id)| *def_id == tcx.lang_items().sized_trait());
if let Some((constraint, def_id)) = sized_constraints.next() {
if let Some((_, def_id)) = sized_constraints.next() {
applicability = Applicability::MaybeIncorrect;

err.span_label(
param.span,
format!("this type parameter needs to be `{}`", constraint),
);
err.span_label(param.span, "this type parameter needs to be `Sized`");
suggest_changing_unsized_bound(generics, &mut suggestions, param, def_id);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/const-argument-if-length.rs:15:12
|
LL | pub struct AtLeastByte<T: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
LL | value: T,
| ^ doesn't have a size known at compile-time
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/const-argument-if-length.rs:15:12
|
LL | pub struct AtLeastByte<T: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
LL | value: T,
| ^ doesn't have a size known at compile-time
|
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/dst/dst-object-from-unsized-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/dst-object-from-unsized-type.rs:8:23
|
LL | fn test1<T: ?Sized + Foo>(t: &T) {
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
LL | let u: &dyn Foo = t;
| ^ doesn't have a size known at compile-time
|
Expand All @@ -17,7 +17,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/dst-object-from-unsized-type.rs:13:23
|
LL | fn test2<T: ?Sized + Foo>(t: &T) {
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
LL | let v: &dyn Foo = t as &dyn Foo;
| ^ doesn't have a size known at compile-time
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/generic-associated-types/issue-88287.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim
--> $DIR/issue-88287.rs:34:9
|
LL | type SearchFutureTy<'f, A, B: 'f>
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
...
LL | async move { todo!() }
| ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/offset-of/offset-of-dst-field.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/offset-of-dst-field.rs:50:5
|
LL | fn generic_with_maybe_sized<T: ?Sized>() -> usize {
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
LL | offset_of!(Delta<T>, z)
| ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/packed/issue-27060-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/issue-27060-2.rs:3:11
|
LL | pub struct Bad<T: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
LL | data: T,
| ^ doesn't have a size known at compile-time
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/adt-param-with-implicit-sized-bound.rs:25:9
|
LL | struct Struct5<T: ?Sized>{
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
LL | _t: X<T>,
| ^^^^ doesn't have a size known at compile-time
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
LL | fn foo<T>(foo: Wrapper<T>)
| - ^^^^^^^^^^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
| this type parameter needs to be `Sized`
|
note: required by a bound in `Wrapper`
--> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:1:16
Expand Down Expand Up @@ -33,7 +33,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
LL | fn bar<T>(foo: Wrapper<T>)
| - ^^^^^^^^^^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
| this type parameter needs to be `Sized`
|
note: required by a bound in `Wrapper`
--> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:1:16
Expand All @@ -58,7 +58,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
LL | fn qux<T>(foo: Wrapper<T>)
| - ^^^^^^^^^^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
| this type parameter needs to be `Sized`
|
note: required by a bound in `Wrapper`
--> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:1:16
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/trait-bounds/apit-unsized.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `impl Iterator<Item = i32> + ?Sized` c
--> $DIR/apit-unsized.rs:1:8
|
LL | fn foo(_: impl Iterator<Item = i32> + ?Sized) {}
| ^ ---------------------------------- this type parameter needs to be `std::marker::Sized`
| ^ ---------------------------------- this type parameter needs to be `Sized`
| |
| doesn't have a size known at compile-time
|
Expand All @@ -21,7 +21,7 @@ error[E0277]: the size for values of type `impl ?Sized` cannot be known at compi
--> $DIR/apit-unsized.rs:2:8
|
LL | fn bar(_: impl ?Sized) {}
| ^ ----------- this type parameter needs to be `std::marker::Sized`
| ^ ----------- this type parameter needs to be `Sized`
| |
| doesn't have a size known at compile-time
|
Expand Down
30 changes: 13 additions & 17 deletions tests/ui/trait-bounds/unsized-bound.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `B` cannot be known at compilation tim
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`
| this type parameter needs to be `Sized`
|
= note: required because it appears within the type `(A, B)`
note: required by a bound in `Trait`
Expand All @@ -28,7 +28,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim
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`
| this type parameter needs to be `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`
Expand All @@ -43,7 +43,7 @@ error[E0277]: the size for values of type `C` cannot be known at compilation tim
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`
| this type parameter needs to be `Sized`
|
= note: required because it appears within the type `(A, B, C)`
note: required by a bound in `Trait`
Expand All @@ -65,9 +65,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim
--> $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`
| - this type parameter needs to be `Sized` ^^^^^^^^^ 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`
Expand All @@ -80,9 +78,7 @@ error[E0277]: the size for values of type `B` cannot be known at compilation tim
--> $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`
| - this type parameter needs to be `Sized` ^^^^^^^^^ 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`
Expand All @@ -97,7 +93,7 @@ error[E0277]: the size for values of type `B` cannot be known at compilation tim
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`
| this type parameter needs to be `Sized`
|
= note: required because it appears within the type `(A, B)`
note: required by a bound in `Trait2`
Expand All @@ -121,7 +117,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim
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`
| this type parameter needs to be `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`
Expand All @@ -136,7 +132,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim
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`
| this type parameter needs to be `Sized`
|
note: required by a bound in `Trait3`
--> $DIR/unsized-bound.rs:13:14
Expand All @@ -159,7 +155,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim
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`
| this type parameter needs to be `Sized`
|
note: required by a bound in `Trait4`
--> $DIR/unsized-bound.rs:16:14
Expand All @@ -182,7 +178,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
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`
| this type parameter needs to be `Sized`
|
note: required by a bound in `Trait5`
--> $DIR/unsized-bound.rs:19:14
Expand All @@ -205,7 +201,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
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`
| this type parameter needs to be `Sized`
|
note: required by a bound in `Trait6`
--> $DIR/unsized-bound.rs:22:14
Expand All @@ -228,7 +224,7 @@ error[E0277]: the size for values of type `Y` cannot be known at compilation tim
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`
| this type parameter needs to be `Sized`
|
note: required by a bound in `Trait7`
--> $DIR/unsized-bound.rs:25:17
Expand All @@ -251,7 +247,7 @@ error[E0277]: the size for values of type `Y` cannot be known at compilation tim
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`
| this type parameter needs to be `Sized`
|
note: required by a bound in `Trait8`
--> $DIR/unsized-bound.rs:28:17
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/traits/suggest-where-clause.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `U` cannot be known at compilation tim
--> $DIR/suggest-where-clause.rs:7:20
|
LL | fn check<T: Iterator, U: ?Sized>() {
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
LL | // suggest a where-clause, if needed
LL | mem::size_of::<U>();
| ^ doesn't have a size known at compile-time
Expand All @@ -19,7 +19,7 @@ error[E0277]: the size for values of type `U` cannot be known at compilation tim
--> $DIR/suggest-where-clause.rs:10:20
|
LL | fn check<T: Iterator, U: ?Sized>() {
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
...
LL | mem::size_of::<Misc<U>>();
| ^^^^^^^ doesn't have a size known at compile-time
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/union/union-sized-field.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/union-sized-field.rs:4:12
|
LL | union Foo<T: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
LL | value: ManuallyDrop<T>,
| ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
Expand All @@ -28,7 +28,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/union-sized-field.rs:9:12
|
LL | struct Foo2<T: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
LL | value: ManuallyDrop<T>,
| ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
Expand All @@ -54,7 +54,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/union-sized-field.rs:15:11
|
LL | enum Foo3<T: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
LL | Value(ManuallyDrop<T>),
| ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/unsized/unsized-bare-typaram.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
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`
| this type parameter needs to be `Sized`
|
note: required by a bound in `bar`
--> $DIR/unsized-bare-typaram.rs:1:8
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/unsized/unsized-enum.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
LL | fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
| - ^^^^^^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
| this type parameter needs to be `Sized`
|
note: required by a bound in `Foo`
--> $DIR/unsized-enum.rs:4:10
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/unsized/unsized-enum2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `W` cannot be known at compilation tim
--> $DIR/unsized-enum2.rs:23:8
|
LL | enum E<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
LL | // parameter
LL | VA(W),
| ^ doesn't have a size known at compile-time
Expand All @@ -27,7 +27,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
--> $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`
| - this type parameter needs to be `Sized`
...
LL | VB{x: X},
| ^ doesn't have a size known at compile-time
Expand All @@ -52,7 +52,7 @@ error[E0277]: the size for values of type `Y` cannot be known at compilation tim
--> $DIR/unsized-enum2.rs:27:15
|
LL | enum E<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
| - this type parameter needs to be `Sized`
...
LL | VC(isize, Y),
| ^ doesn't have a size known at compile-time
Expand All @@ -77,7 +77,7 @@ error[E0277]: the size for values of type `Z` cannot be known at compilation tim
--> $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`
| - this type parameter needs to be `Sized`
...
LL | VD{u: isize, x: Z},
| ^ doesn't have a size known at compile-time
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/unsized/unsized-fn-arg.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
LL | fn f<T: ?Sized>(t: T) {}
| - ^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
| this type parameter needs to be `Sized`
|
= help: unsized fn params are gated as an unstable feature
help: consider removing the `?Sized` bound to make the type parameter `Sized`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/unsized/unsized-inherent-impl-self-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
LL | impl<X: ?Sized> S5<X> {
| - ^^^^^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
| this type parameter needs to be `Sized`
|
note: required by a bound in `S5`
--> $DIR/unsized-inherent-impl-self-type.rs:5:11
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/unsized/unsized-struct.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
LL | fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
| - ^^^^^^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
| this type parameter needs to be `Sized`
|
note: required by a bound in `Foo`
--> $DIR/unsized-struct.rs:4:12
Expand All @@ -30,7 +30,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
LL | fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() }
| - ^^^^^^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
| this type parameter needs to be `Sized`
|
note: required because it appears within the type `Bar<T>`
--> $DIR/unsized-struct.rs:11:8
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/unsized/unsized-trait-impl-self-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
LL | impl<X: ?Sized> T3<X> for S5<X> {
| - ^^^^^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
| this type parameter needs to be `Sized`
|
note: required by a bound in `S5`
--> $DIR/unsized-trait-impl-self-type.rs:8:11
Expand Down
Loading

0 comments on commit b6a3f12

Please sign in to comment.