Skip to content

Commit d3e70a3

Browse files
committed
update mapped_lock_guard features
1 parent c0b5aab commit d3e70a3

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

library/std/src/sync/nonpoison/mutex.rs

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ unsafe impl<T: ?Sized + Sync> Sync for MutexGuard<'_, T> {}
235235
#[must_not_suspend = "holding a MappedMutexGuard across suspend \
236236
points can cause deadlocks, delays, \
237237
and cause Futures to not implement `Send`"]
238-
// #[unstable(feature = "mapped_lock_guards", issue = "117108")]
239-
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
238+
#[unstable(feature = "mapped_lock_guards", issue = "117108")]
240239
#[clippy::has_significant_drop]
241240
pub struct MappedMutexGuard<'a, T: ?Sized + 'a> {
242241
// NB: we use a pointer instead of `&'a mut T` to avoid `noalias` violations, because a
@@ -248,11 +247,9 @@ pub struct MappedMutexGuard<'a, T: ?Sized + 'a> {
248247
_variance: PhantomData<&'a mut T>,
249248
}
250249

251-
// #[unstable(feature = "mapped_lock_guards", issue = "117108")]
252-
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
250+
#[unstable(feature = "mapped_lock_guards", issue = "117108")]
253251
impl<T: ?Sized> !Send for MappedMutexGuard<'_, T> {}
254-
// #[unstable(feature = "mapped_lock_guards", issue = "117108")]
255-
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
252+
#[unstable(feature = "mapped_lock_guards", issue = "117108")]
256253
unsafe impl<T: ?Sized + Sync> Sync for MappedMutexGuard<'_, T> {}
257254

258255
impl<T> Mutex<T> {
@@ -272,7 +269,7 @@ impl<T> Mutex<T> {
272269
Mutex { inner: sys::Mutex::new(), data: UnsafeCell::new(t) }
273270
}
274271

275-
// FIXME(connor): Add `lock_value_accessors` feature methods.
272+
// FIXME: Add `lock_value_accessors` feature methods.
276273
}
277274

278275
impl<T: ?Sized> Mutex<T> {
@@ -392,7 +389,7 @@ impl<T: ?Sized> Mutex<T> {
392389
self.data.get_mut()
393390
}
394391

395-
// FIXME(connor): Add `mutex_data_ptr` feature method.
392+
// FIXME: Add `mutex_data_ptr` feature method.
396393
}
397394

398395
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
@@ -483,8 +480,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> {
483480
/// This is an associated function that needs to be used as
484481
/// `MutexGuard::map(...)`. A method would interfere with methods of the
485482
/// same name on the contents of the `MutexGuard` used through `Deref`.
486-
// #[unstable(feature = "mapped_lock_guards", issue = "117108")]
487-
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
483+
#[unstable(feature = "mapped_lock_guards", issue = "117108")]
488484
pub fn map<U, F>(orig: Self, f: F) -> MappedMutexGuard<'a, U>
489485
where
490486
F: FnOnce(&mut T) -> &mut U,
@@ -509,8 +505,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> {
509505
/// `MutexGuard::try_map(...)`. A method would interfere with methods of the
510506
/// same name on the contents of the `MutexGuard` used through `Deref`.
511507
#[doc(alias = "filter_map")]
512-
// #[unstable(feature = "mapped_lock_guards", issue = "117108")]
513-
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
508+
#[unstable(feature = "mapped_lock_guards", issue = "117108")]
514509
pub fn try_map<U, F>(orig: Self, f: F) -> Result<MappedMutexGuard<'a, U>, Self>
515510
where
516511
F: FnOnce(&mut T) -> Option<&mut U>,
@@ -531,8 +526,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> {
531526
}
532527
}
533528

534-
// #[unstable(feature = "mapped_lock_guards", issue = "117108")]
535-
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
529+
#[unstable(feature = "mapped_lock_guards", issue = "117108")]
536530
impl<T: ?Sized> Deref for MappedMutexGuard<'_, T> {
537531
type Target = T;
538532

@@ -541,16 +535,14 @@ impl<T: ?Sized> Deref for MappedMutexGuard<'_, T> {
541535
}
542536
}
543537

544-
// #[unstable(feature = "mapped_lock_guards", issue = "117108")]
545-
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
538+
#[unstable(feature = "mapped_lock_guards", issue = "117108")]
546539
impl<T: ?Sized> DerefMut for MappedMutexGuard<'_, T> {
547540
fn deref_mut(&mut self) -> &mut T {
548541
unsafe { self.data.as_mut() }
549542
}
550543
}
551544

552-
// #[unstable(feature = "mapped_lock_guards", issue = "117108")]
553-
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
545+
#[unstable(feature = "mapped_lock_guards", issue = "117108")]
554546
impl<T: ?Sized> Drop for MappedMutexGuard<'_, T> {
555547
#[inline]
556548
fn drop(&mut self) {
@@ -560,16 +552,14 @@ impl<T: ?Sized> Drop for MappedMutexGuard<'_, T> {
560552
}
561553
}
562554

563-
// #[unstable(feature = "mapped_lock_guards", issue = "117108")]
564-
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
555+
#[unstable(feature = "mapped_lock_guards", issue = "117108")]
565556
impl<T: ?Sized + fmt::Debug> fmt::Debug for MappedMutexGuard<'_, T> {
566557
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
567558
fmt::Debug::fmt(&**self, f)
568559
}
569560
}
570561

571-
// #[unstable(feature = "mapped_lock_guards", issue = "117108")]
572-
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
562+
#[unstable(feature = "mapped_lock_guards", issue = "117108")]
573563
impl<T: ?Sized + fmt::Display> fmt::Display for MappedMutexGuard<'_, T> {
574564
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
575565
(**self).fmt(f)
@@ -585,15 +575,14 @@ impl<'a, T: ?Sized> MappedMutexGuard<'a, T> {
585575
/// This is an associated function that needs to be used as
586576
/// `MappedMutexGuard::map(...)`. A method would interfere with methods of the
587577
/// same name on the contents of the `MutexGuard` used through `Deref`.
588-
// #[unstable(feature = "mapped_lock_guards", issue = "117108")]
589-
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
578+
#[unstable(feature = "mapped_lock_guards", issue = "117108")]
590579
pub fn map<U, F>(mut orig: Self, f: F) -> MappedMutexGuard<'a, U>
591580
where
592581
F: FnOnce(&mut T) -> &mut U,
593582
U: ?Sized,
594583
{
595584
// SAFETY: the conditions of `MutexGuard::new` were satisfied when the original guard
596-
// was created, and have been upheld throughout `map` and/or `try_map`.
585+
// was created, and have been upheld throughout `map` and/or `filter_map`.
597586
// The signature of the closure guarantees that it will not "leak" the lifetime of the reference
598587
// passed to it. If the closure panics, the guard will be dropped.
599588
let data = NonNull::from(f(unsafe { orig.data.as_mut() }));
@@ -608,17 +597,16 @@ impl<'a, T: ?Sized> MappedMutexGuard<'a, T> {
608597
/// The `Mutex` is already locked, so this cannot fail.
609598
///
610599
/// This is an associated function that needs to be used as
611-
/// `MappedMutexGuard::try_map(...)`. A method would interfere with methods of the
600+
/// `MappedMutexGuard::filter_map(...)`. A method would interfere with methods of the
612601
/// same name on the contents of the `MutexGuard` used through `Deref`.
613-
#[doc(alias = "filter_map")]
614-
#[unstable(feature = "nonpoison_mutex", issue = "134645")]
615-
pub fn try_map<U, F>(mut orig: Self, f: F) -> Result<MappedMutexGuard<'a, U>, Self>
602+
#[unstable(feature = "mapped_lock_guards", issue = "117108")]
603+
pub fn filter_map<U, F>(mut orig: Self, f: F) -> Result<MappedMutexGuard<'a, U>, Self>
616604
where
617605
F: FnOnce(&mut T) -> Option<&mut U>,
618606
U: ?Sized,
619607
{
620608
// SAFETY: the conditions of `MutexGuard::new` were satisfied when the original guard
621-
// was created, and have been upheld throughout `map` and/or `try_map`.
609+
// was created, and have been upheld throughout `map` and/or `filter_map`.
622610
// The signature of the closure guarantees that it will not "leak" the lifetime of the reference
623611
// passed to it. If the closure panics, the guard will be dropped.
624612
match f(unsafe { orig.data.as_mut() }) {

0 commit comments

Comments
 (0)