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

KnownLayout tracks pointer metadata type #995

Merged
merged 1 commit into from Apr 23, 2024
Merged

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented Mar 1, 2024

Makes progress on #29

@joshlf joshlf force-pushed the known-layout-metadata branch 3 times, most recently from 9c18f87 to 304f572 Compare March 2, 2024 01:59
@joshlf joshlf changed the base branch from main to deprecate-ref-constructors March 2, 2024 02:00
Base automatically changed from deprecate-ref-constructors to main March 2, 2024 03:20
@joshlf joshlf force-pushed the known-layout-metadata branch 3 times, most recently from abe69ee to ef40641 Compare April 23, 2024 21:08
@joshlf joshlf marked this pull request as ready for review April 23, 2024 21:13
@joshlf joshlf requested a review from jswrenn April 23, 2024 21:14
Comment on lines +1068 to +1070
/// `()` for sized types and `usize` for slice DSTs.
#[doc(hidden)]
type PointerMetadata: PointerMetadata;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might want to remove the doc(hidden) here once this appears in where bounds.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in the next PR.

src/lib.rs Outdated
Comment on lines 1091 to 1092
/// What is the size of the object with the given layout and pointer
/// metadata?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// What is the size of the object with the given layout and pointer
/// metadata?
/// Computes the size of the object with the given layout and pointer
/// metadata.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

src/lib.rs Outdated
fn size_for_metadata(&self, layout: DstLayout) -> Option<usize> {
match layout.size_info {
SizeInfo::Sized { size } => Some(size),
SizeInfo::SliceDst(_) => unreachable!(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the interest of minimizing our panic paths, perhaps we should do something besides unreachable!(), like return None.

(We can't use unreachable_unchecked(), because this method is safe and this line is obviously not actually unreachable when evaluated in isolation.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@jswrenn jswrenn added this pull request to the merge queue Apr 23, 2024
Merged via the queue into main with commit 0b8b529 Apr 23, 2024
210 checks passed
@jswrenn jswrenn deleted the known-layout-metadata branch April 23, 2024 21:52
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.

None yet

2 participants