rust-lang / rust-lang/rust

Tracking Issue for {Mutex, RwLock, ReentrantLock}::data_ptr

Open
#140,368 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue S-tracking-unimplemented T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Feature gate: #![feature(mutex_data_ptr)], #![feature(rwlock_data_ptr)], #![feature(reentrant_lock_data_ptr)]

This is a tracking issue for allowing unguarded access to the inner value of a Mutex or RwLock. Previous discussion here: https://github.com/rust-lang/libs-team/issues/531

Public API
// std::sync

impl<T: ?Sized> Mutex<T> {
    pub fn data_ptr(&self) -> *mut T;
}

impl<T: ?Sized> RwLock<T> {
    pub fn data_ptr(&self) -> *mut T;
}

// This type is unstable under feature `reentrant_lock`
impl<T: ?Sized> ReentrantLock<T>  {
    pub fn data_ptr(&self) -> *mut T;
}
Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

  • Implementation: #140369
  • Add examples to documentation
  • Final comment period (FCP)^1
  • Stabilization PR
Unresolved Questions
  • Return a LockResult or not?
  • Return *mut T like existing APIs (Cell::as_ptr / MaybeUninit::as[_mut]_ptr / Vec::as_ptr / ...) or be more precise and return NonNull<T>?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The implementation is complete in #140369; begin by reviewing that change and the existing Mutex, RwLock, and ReentrantLock API documentation. Add usage examples for data_ptr to the relevant standard-library documentation, then verify the examples build and update the tracking checklist. The unresolved return-type questions and FCP/stabilization steps require library-team review rather than an independent code change.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.