Closed
Description
Given the following code: (playground)
struct A<T>(T) where T: Send;
struct B(A<[u8]>);
The current output is:
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> src/lib.rs:2:10
|
1 | struct A<T>(T) where T: Send;
| - required by this bound in `A`
2 | struct B(A<[u8]>);
| ^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
--> src/lib.rs:1:10
|
1 | struct A<T>(T) where T: Send;
| ^ - - ...if indirection were used here: `Box<T>`
| | |
| | ...if indirection were used here: `Box<T>`
| this could be changed to `T: ?Sized`...
Ideally the output should look like:
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> src/lib.rs:2:10
|
1 | struct A<T>(T) where T: Send;
| - required by this bound in `A`
2 | struct B(A<[u8]>);
| ^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
--> src/lib.rs:1:10
|
1 | struct A<T>(T) where T: Send;
| ^ -
| | |
| | ...if indirection were used here: `Box<T>`
| this could be changed to `T: ?Sized`...
The visitor that collects bare type parameters should skip where clauses. I can work on this in an in-progress pull request where I'm making other improvements to unsized suggestions.
@rustbot claim
@rustbot label +A-traits +A-typesystem +D-invalid-suggestion +D-papercut