-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mention implicit T: Sized
bound in E0277 errors
#69791
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Extracted from #69709. |
Also, I'm not sure this PR handles weird cases like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As is, the message doesn't seem that helpful to me -- see thoughts below.
@@ -6,7 +6,7 @@ LL | fn test1<T: ?Sized + Foo>(t: &T) { | |||
LL | let u: &dyn Foo = t; | |||
| ^ doesn't have a size known at compile-time | |||
| | |||
= help: the trait `std::marker::Sized` is not implemented for `T` | |||
= help: type parameters have an implicit `Sized` requirement by default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, these help messages seem to be kind of confusing to me. That is, just looking at the error message, I can't really tell what it's talking about here.
@@ -12,7 +12,7 @@ LL | mem::size_of::<U>(); | |||
LL | pub const fn size_of<T>() -> usize { | |||
| - required by this bound in `std::mem::size_of` | |||
| | |||
= help: the trait `std::marker::Sized` is not implemented for `U` | |||
= help: type parameters have an implicit `Sized` requirement by default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a case where it kind of makes sense, but I feel like we would ideally want it to be in place of the "required by this bound" message. e.g., something like
pub const fn size_of<T>
- required because of the default `Sized` requirement on this type parameter
No description provided.