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

Improve IntoBytes derive error message #1713

Merged
merged 1 commit into from
Sep 21, 2024
Merged

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented Sep 20, 2024

Closes #1708

@joshlf
Copy link
Member Author

joshlf commented Sep 20, 2024

@jswrenn if you're on board with this, I think this can supersede #1710.

@joshlf joshlf force-pushed the into-bytes-improve-unsized-error branch from e38839b to b42cfb6 Compare September 20, 2024 23:54
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.79%. Comparing base (7eb4026) to head (b42cfb6).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1713   +/-   ##
=======================================
  Coverage   88.79%   88.79%           
=======================================
  Files          16       16           
  Lines        5843     5846    +3     
=======================================
+ Hits         5188     5191    +3     
  Misses        655      655           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

#[inline(always)]
#[must_use]
#[allow(clippy::needless_maybe_sized)]
pub const fn size_of<T: Sized + ?core::marker::Sized>() -> usize {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is such a cursed bound.

--> tests/ui-nightly/struct.rs:129:8
|
129 | b: [u8],
| ^^^^ `IntoBytes` needs all field types to be `Sized` in order to determine whether there is inter-field padding
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NICE!

@joshlf joshlf added this pull request to the merge queue Sep 21, 2024
Merged via the queue into main with commit 553996e Sep 21, 2024
86 checks passed
@joshlf joshlf deleted the into-bytes-improve-unsized-error branch September 21, 2024 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve ergonomics of IntoBytes on unsized types
3 participants