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

Add safety documentation #2344

Merged
merged 7 commits into from
Jan 29, 2025
Merged

Add safety documentation #2344

merged 7 commits into from
Jan 29, 2025

Conversation

aumetra
Copy link
Member

@aumetra aumetra commented Jan 21, 2025

Closes #2305

I hope this documentation makes it a little clearer why the usage here is sound.
Best proof-read by someone that isn't me to make sure what I wrote is actually coherent for others.

@aumetra
Copy link
Member Author

aumetra commented Jan 21, 2025

I guess the part where we say "pointer is required to be non-null can be covered by simply utilizing the std::ptr::NonNull type. Also opens up some fun Option optimizations (not that we really need them) where Option<Region> == Region since they can encode the Option tag as ptr == ptr::null()

packages/std/src/memory.rs Outdated Show resolved Hide resolved
packages/std/src/memory.rs Outdated Show resolved Hide resolved
packages/std/src/memory.rs Outdated Show resolved Hide resolved
packages/std/src/memory.rs Outdated Show resolved Hide resolved
@chipshort
Copy link
Collaborator

simply utilizing the std::ptr::NonNull type

That sounds nice. I'm always a fan of enforcing correct usage through the type system where possible.

@aumetra
Copy link
Member Author

aumetra commented Jan 28, 2025

(had to fix up the Changelog a bit)

@aumetra aumetra requested a review from chipshort January 28, 2025 10:49
@aumetra aumetra force-pushed the aw/memory-safety-doc branch from 59c6d59 to 56d9d29 Compare January 28, 2025 11:20
Copy link
Collaborator

@chipshort chipshort left a comment

Choose a reason for hiding this comment

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

LGTM

@aumetra aumetra merged commit 9d5bfef into main Jan 29, 2025
39 checks passed
@aumetra aumetra deleted the aw/memory-safety-doc branch January 29, 2025 15:04
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.

Maybe unsound in as_bytes
2 participants