-
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-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)
fn foo<T>(_: &T) where T: Sized {}
fn bar() { foo(""); }
The current output is:
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> src/lib.rs:2:16
|
1 | fn foo<T>(_: &T) where T: Sized {}
| - required by this bound in `foo`
2 | fn bar() { foo(""); }
| ^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
help: consider relaxing the implicit `Sized` restriction
|
1 | fn foo<T: ?Sized>(_: &T) where T: Sized {}
| ^^^^^^^^
Ideally, the diagnostic shouldn't suggest relaxing an explicit Sized
bound in the where clause. (There is already code that skips the ?Sized
suggestion for type parameters that have an explicit Sized
bound.)
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-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-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.