Skip to content

Update documentation of as_ptr function of Atomic$Int to clarify circumstances of usage #139637

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

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

Conversation

madhav-madhusoodanan
Copy link
Contributor

Context

The documentation of as_ptr mentions that "operations on it must be atomic". This may confuse developers, since non-atomic reads may be safely performed in certain circumstances (eg: when they do not lead to a data race).

The core message is that non-atomic accesses are UB if they cause a data race.

This update ensures such clarity on the circumstances of usage of the as_ptr function.

Associated Issue

cc: @RalfJung @briansmith

@rustbot
Copy link
Collaborator

rustbot commented Apr 10, 2025

r? @thomcc

rustbot has assigned @thomcc.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 10, 2025
@madhav-madhusoodanan madhav-madhusoodanan changed the title Update documentation of Atomic$Int types' as_ptr to reflect that its usage must not lead to data races Update documentation of as_ptr function of Atomic$Int to reflect that its usage must not lead to data races Apr 10, 2025
@madhav-madhusoodanan madhav-madhusoodanan changed the title Update documentation of as_ptr function of Atomic$Int to reflect that its usage must not lead to data races Update documentation of as_ptr function of Atomic$Int to clarify circumstances of usage Apr 10, 2025
Copy link
Contributor

@briansmith briansmith left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on.

@rust-log-analyzer

This comment has been minimized.

@madhav-madhusoodanan
Copy link
Contributor Author

I've added an example where there is no unsafe block being used.
Do let me know if its a good example.

@RalfJung
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 17, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 17, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@madhav-madhusoodanan
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 18, 2025
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. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants