Skip to content

Rollup of 10 pull requests #98367

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

Closed
wants to merge 31 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f020fc0
clarify how Rust atomics correspond to C++ atomics
RalfJung May 29, 2022
8b7299d
Remove `likely!` and `unlikely!` macro from compiler
nbdd0121 May 31, 2022
44364dc
Add release notes for 1.62
Mark-Simulacrum May 27, 2022
7cefa8f
Make RwLockReadGuard covariant
r-raymond May 7, 2022
0b6e6e3
Formatting
r-raymond Jun 19, 2022
391f800
More formatting
r-raymond May 7, 2022
cf1238e
Address comments
r-raymond May 13, 2022
08650fb
*const to NonNull plus documentation
r-raymond May 14, 2022
0157593
Documentation typo
r-raymond May 14, 2022
fa1656e
Add safety comments
r-raymond May 26, 2022
09d937e
Add comment explaining why we use NonNull
r-raymond Jun 16, 2022
cb20e25
Add test to verify noalias is not being added
r-raymond Jun 19, 2022
43c6f9c
Make sure we don't match noalias in later lines
r-raymond Jun 19, 2022
048a801
UnsafeCell -> RwLock
r-raymond Jun 20, 2022
ac38258
Use futex based thread parker on Fuchsia.
m-ou-se May 6, 2022
8eb7ddf
update cpu-usage-over-time-plot script
seanpray Mar 29, 2022
c9340ec
Fix typo
lucasthormann Jun 21, 2022
1ca8b69
remove use of &Alloc in btree tests
RalfJung Jun 21, 2022
4768bfc
hedge our bets
RalfJung Jun 21, 2022
52409c4
Point at return expression for RPIT-related error
compiler-errors Jun 7, 2022
e53b2ba
Add some tests for impossible bounds
compiler-errors Jun 11, 2022
ecda292
Rollup merge of #95446 - notseanray:master, r=Mark-Simulacrum
JohnTitor Jun 22, 2022
4415af5
Rollup merge of #96768 - m-ou-se:futex-fuchsia, r=tmandry
JohnTitor Jun 22, 2022
c7aa270
Rollup merge of #96820 - r-raymond:master, r=cuviper
JohnTitor Jun 22, 2022
ffd6b0f
Rollup merge of #97454 - Mark-Simulacrum:relnotes, r=Mark-Simulacrum
JohnTitor Jun 22, 2022
39520e4
Rollup merge of #97516 - RalfJung:atomics, r=joshtriplett
JohnTitor Jun 22, 2022
3543cd7
Rollup merge of #97818 - compiler-errors:rpit-error-spanned, r=oli-obk
JohnTitor Jun 22, 2022
a07def6
Rollup merge of #97895 - nbdd0121:unlikely, r=estebank
JohnTitor Jun 22, 2022
5b0093a
Rollup merge of #98005 - compiler-errors:impossible-bounds, r=Mark-Si…
JohnTitor Jun 22, 2022
824443d
Rollup merge of #98356 - lucasthormann:patch-1, r=Mark-Simulacrum
JohnTitor Jun 22, 2022
ae8c200
Rollup merge of #98363 - RalfJung:btree-test-ref-alloc, r=thomcc
JohnTitor Jun 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
*const to NonNull plus documentation
  • Loading branch information
r-raymond committed Jun 19, 2022
commit 08650fbb506c44fbc95d91abfb7cd95a56bbff30
15 changes: 12 additions & 3 deletions library/std/src/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod tests;
use crate::cell::UnsafeCell;
use crate::fmt;
use crate::ops::{Deref, DerefMut};
use crate::ptr::NonNull;
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
use crate::sys_common::rwlock as sys;

Expand Down Expand Up @@ -101,7 +102,7 @@ unsafe impl<T: ?Sized + Send + Sync> Sync for RwLock<T> {}
#[stable(feature = "rust1", since = "1.0.0")]
#[clippy::has_significant_drop]
pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
data: *const T,
data: NonNull<T>,
inner_lock: &'a sys::MovableRwLock,
}

Expand Down Expand Up @@ -510,15 +511,23 @@ impl<T> From<T> for RwLock<T> {
}

impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> {
/// Create a new instance of `RwLockReadGuard<T>` from a `RwLock<T>`.
///
/// It is safe to call this function if and only if `lock.inner.read()` (or
/// `lock.inner.try_read()`) has been successfully called before instantiating this object.
unsafe fn new(lock: &'rwlock RwLock<T>) -> LockResult<RwLockReadGuard<'rwlock, T>> {
poison::map_result(lock.poison.borrow(), |()| RwLockReadGuard {
data: NonNull::new_unchecked(lock.data.get()),
inner_lock: &lock.inner,
data: lock.data.get(),
})
}
}

impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> {
/// Create a new instance of `RwLockReadGuard<T>` from a `RwLock<T>`.
///
/// It is safe to call this function if and only if `lock.inner.write()` (or
/// `lock.inner.try_write()`) has been successfully called before instantiating this object.
unsafe fn new(lock: &'rwlock RwLock<T>) -> LockResult<RwLockWriteGuard<'rwlock, T>> {
poison::map_result(lock.poison.guard(), |guard| RwLockWriteGuard { lock, poison: guard })
}
Expand Down Expand Up @@ -557,7 +566,7 @@ impl<T: ?Sized> Deref for RwLockReadGuard<'_, T> {
type Target = T;

fn deref(&self) -> &T {
unsafe { &*self.data }
unsafe { self.data.as_ref() }
}
}

Expand Down