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
Given the following code: (playground)
The current output is:
Ideally, the diagnostic shouldn't suggest relaxing an explicit
Sizedbound in the where clause. (There is already code that skips the?Sizedsuggestion for type parameters that have an explicitSizedbound.)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