Add data_ptr method to Mutex and RwLock by jplatte · Pull Request #140369 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation11 Commits3 Checks6 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Implementation of #140368 / rust-lang/libs-team#531.
I tried to write a useful safety section about when it is safe to read or write through the returned pointers, but couldn't come up with something nice. Hoping this PR is still useful without that. I'm happy to add any doc strings other people come up with if needed before merge, of course.
Unresolved questions:
- Return a
LockResultor not? - Return
*mut Tlike existing APIs (Cell::as_ptr/MaybeUninit::as[_mut]_ptr/Vec::as_ptr/ ...) or be more precise and returnNonNull<T>?
r? @tgross35
rustbot has assigned @tgross35.
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 added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the library team, which will review and decide on the PR/issue.
labels
This seems fine to me, but libs-api didn't specify an exact API so I'll ask them to review.
r? @Amanieu
Can you add this for ReentrantLock as well?
Also add a sentence to the docs saying that you are responsible for ensuring that accesses to the data are synchronized properly.
This comment has been minimized.
I wasn't previously familiar with the unstable ReentrantLock. It looks like it doesn't directly allow writes so I've made the data_ptr method return *const T and made its docs only talk about reads, not writes.
Do you have any comments about the unresolved questions?
📌 Commit 20589bd has been approved by Amanieu
It is now in the queue for this repository.
bors added S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
bors added a commit that referenced this pull request
Add data_ptr method to Mutex and RwLock
Implementation of #140368 / rust-lang/libs-team#531.
I tried to write a useful safety section about when it is safe to read or write through the returned pointers, but couldn't come up with something nice. Hoping this PR is still useful without that. I'm happy to add any doc strings other people come up with if needed before merge, of course.
Unresolved questions:
- Return a
LockResultor not? - Return
*mut Tlike existing APIs (Cell::as_ptr/MaybeUninit::as[_mut]_ptr/Vec::as_ptr/ ...) or be more precise and returnNonNull<T>?
bors added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
and removed S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
labels
A job failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
No reason for this to time out.
@bors retry
@jplatte these could use example doctests at some point, feel free to either add them here or in a follow up.
bors added S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
tgross35 added a commit to tgross35/rust that referenced this pull request
…manieu
Add data_ptr method to Mutex and RwLock
Implementation of rust-lang#140368 / rust-lang/libs-team#531.
I tried to write a useful safety section about when it is safe to read or write through the returned pointers, but couldn't come up with something nice. Hoping this PR is still useful without that. I'm happy to add any doc strings other people come up with if needed before merge, of course.
Unresolved questions:
- Return a
LockResultor not? - Return
*mut Tlike existing APIs (Cell::as_ptr/MaybeUninit::as[_mut]_ptr/Vec::as_ptr/ ...) or be more precise and returnNonNull<T>?
bors added a commit that referenced this pull request
Rollup of 8 pull requests
Successful merges:
- #140369 (Add data_ptr method to Mutex and RwLock)
- #140697 (Split
autodiffintoautodiff_forwardandautodiff_reverse) - #141404 (Improve intrinsic handling in cg_ssa)
- #141407 (Refactor the two-phase check for impls and impl items)
- #141411 (rustdoc: linking to a local proc macro no longer warns)
- #141548 (consider glob imports in cfg suggestion)
- #141627 (Drop-build cleanups)
- #141670 (Fix ICE in tokenstream with contracts from parser recovery)
r? @ghost
@rustbot modify labels: rollup
jhpratt added a commit to jhpratt/rust that referenced this pull request
…manieu
Add data_ptr method to Mutex and RwLock
Implementation of rust-lang#140368 / rust-lang/libs-team#531.
I tried to write a useful safety section about when it is safe to read or write through the returned pointers, but couldn't come up with something nice. Hoping this PR is still useful without that. I'm happy to add any doc strings other people come up with if needed before merge, of course.
Unresolved questions:
- Return a
LockResultor not? - Return
*mut Tlike existing APIs (Cell::as_ptr/MaybeUninit::as[_mut]_ptr/Vec::as_ptr/ ...) or be more precise and returnNonNull<T>?
bors added a commit that referenced this pull request
Rollup of 8 pull requests
Successful merges:
- #140369 (Add data_ptr method to Mutex and RwLock)
- #140697 (Split
autodiffintoautodiff_forwardandautodiff_reverse) - #141404 (Improve intrinsic handling in cg_ssa)
- #141407 (Refactor the two-phase check for impls and impl items)
- #141411 (rustdoc: linking to a local proc macro no longer warns)
- #141548 (consider glob imports in cfg suggestion)
- #141627 (Drop-build cleanups)
- #141670 (Fix ICE in tokenstream with contracts from parser recovery)
r? @ghost
@rustbot modify labels: rollup
bors added a commit that referenced this pull request
Rollup of 7 pull requests
Successful merges:
- #140369 (Add data_ptr method to Mutex and RwLock)
- #140697 (Split
autodiffintoautodiff_forwardandautodiff_reverse) - #141404 (Improve intrinsic handling in cg_ssa)
- #141411 (rustdoc: linking to a local proc macro no longer warns)
- #141548 (consider glob imports in cfg suggestion)
- #141627 (Drop-build cleanups)
- #141670 (Fix ICE in tokenstream with contracts from parser recovery)
r? @ghost
@rustbot modify labels: rollup
rust-timer added a commit that referenced this pull request
Rollup merge of #140369 - jplatte:mutex-rwlock-data-ptr, r=Amanieu
Add data_ptr method to Mutex and RwLock
Implementation of #140368 / rust-lang/libs-team#531.
I tried to write a useful safety section about when it is safe to read or write through the returned pointers, but couldn't come up with something nice. Hoping this PR is still useful without that. I'm happy to add any doc strings other people come up with if needed before merge, of course.
Unresolved questions:
- Return a
LockResultor not? - Return
*mut Tlike existing APIs (Cell::as_ptr/MaybeUninit::as[_mut]_ptr/Vec::as_ptr/ ...) or be more precise and returnNonNull<T>?
jplatte deleted the mutex-rwlock-data-ptr branch
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request
…manieu
Add data_ptr method to Mutex and RwLock
Implementation of rust-lang#140368 / rust-lang/libs-team#531.
I tried to write a useful safety section about when it is safe to read or write through the returned pointers, but couldn't come up with something nice. Hoping this PR is still useful without that. I'm happy to add any doc strings other people come up with if needed before merge, of course.
Unresolved questions:
- Return a
LockResultor not? - Return
*mut Tlike existing APIs (Cell::as_ptr/MaybeUninit::as[_mut]_ptr/Vec::as_ptr/ ...) or be more precise and returnNonNull<T>?
Labels
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Relevant to the library team, which will review and decide on the PR/issue.