Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Mar 6, 2020

No description provided.

@rust-highfive
Copy link
Collaborator

r? @ecstatic-morse

(rust_highfive has picked a reviewer for you, use r? to override)

@estebank
Copy link
Contributor Author

estebank commented Mar 6, 2020

Extracted from #69709.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 6, 2020
@eddyb
Copy link
Member

eddyb commented Mar 7, 2020

r? @nikomatsakis

Also, I'm not sure this PR handles weird cases like T: ?Sized + Copy, or whether it matters.

Copy link
Contributor

@nikomatsakis nikomatsakis left a 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
Copy link
Contributor

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
Copy link
Contributor

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

@estebank estebank closed this Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants