-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemA-type-systemArea: Type systemArea: Type systemD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
estebank
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemA-type-systemArea: Type systemArea: Type systemD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.