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 }})

@jplatte

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:

@rustbot

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 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 27, 2025

@tgross35

This seems fine to me, but libs-api didn't specify an exact API so I'll ask them to review.

r? @Amanieu

@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.

@rustbot

This comment has been minimized.

@jplatte

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?

@Amanieu

@bors

📌 Commit 20589bd has been approved by Amanieu

It is now in the queue for this repository.

@bors 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

May 26, 2025

bors added a commit that referenced this pull request

May 27, 2025

@bors

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:

@bors

@bors

@bors 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

May 27, 2025

@rust-log-analyzer

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@tgross35

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 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

May 28, 2025

tgross35 added a commit to tgross35/rust that referenced this pull request

May 28, 2025

@tgross35

…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:

bors added a commit that referenced this pull request

May 28, 2025

@bors

Rollup of 8 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

jhpratt added a commit to jhpratt/rust that referenced this pull request

May 28, 2025

@jhpratt

…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:

bors added a commit that referenced this pull request

May 28, 2025

@bors

Rollup of 8 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

bors added a commit that referenced this pull request

May 28, 2025

@bors

Rollup of 7 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

rust-timer added a commit that referenced this pull request

May 28, 2025

@rust-timer

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:

@jplatte jplatte deleted the mutex-rwlock-data-ptr branch

May 28, 2025 21:03

github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request

May 30, 2025

@tgross35

…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:

Labels

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.