Skip to content

Commit a99a351

Browse files
authored
sync: use UnsafeCell::get_mut in Mutex::get_mut and RwLock::get_mut (#7569)
1 parent d1e06f8 commit a99a351

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

tokio/src/sync/mutex.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -716,10 +716,7 @@ impl<T: ?Sized> Mutex<T> {
716716
/// }
717717
/// ```
718718
pub fn get_mut(&mut self) -> &mut T {
719-
unsafe {
720-
// Safety: This is https://github.com/rust-lang/rust/pull/76936
721-
&mut *self.c.get()
722-
}
719+
self.c.get_mut()
723720
}
724721

725722
/// Attempts to acquire the lock, and returns [`TryLockError`] if the lock

tokio/src/sync/rwlock.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,10 +1073,7 @@ impl<T: ?Sized> RwLock<T> {
10731073
/// }
10741074
/// ```
10751075
pub fn get_mut(&mut self) -> &mut T {
1076-
unsafe {
1077-
// Safety: This is https://github.com/rust-lang/rust/pull/76936
1078-
&mut *self.c.get()
1079-
}
1076+
self.c.get_mut()
10801077
}
10811078

10821079
/// Consumes the lock, returning the underlying data.

0 commit comments

Comments
 (0)