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

Propose "unsafe fields" as a 2025H1 Project Goal #147

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jswrenn
Copy link
Member

@jswrenn jswrenn commented Nov 4, 2024

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.

This looks good, I'm pruning out some of the "team asks" because I think you don't need them actually.

src/2025h1/unsafe-fields.md Outdated Show resolved Hide resolved
src/2025h1/unsafe-fields.md Outdated Show resolved Hide resolved
src/2025h1/unsafe-fields.md Outdated Show resolved Hide resolved
Comment on lines +71 to +72
3. **Safe Usage is Usually Safe**
Uses of `unsafe` fields which cannot violate their invariants *should not* require an unsafe block.
Copy link
Member

Choose a reason for hiding this comment

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

What does this mean, in practice?

Copy link
Member Author

Choose a reason for hiding this comment

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

For example: Using offset_of has no impact on the safety invariants of its given field. Requiring unsafe { ... } to compute the offset of an unsafe field would be pure noise in an unsafe code review, and, as such, we should make an effort to not require unsafe { ... } in this case.

Unlike the first and second tenet, this tenet is a soft requirement. We shouldn't ignore it entirely in our design work, but we don't actually have to implement any of these safe carve-outs initially since it's forwards-compatible to make an unsafe operation safe (so long as doing so doesn't violate existing safety conditions).

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.

3 participants