From 321a598b7519733aff7dea8b4ebd3631626d656b Mon Sep 17 00:00:00 2001 From: Aaron Kofsky Date: Sun, 5 Jun 2022 01:01:54 -0400 Subject: [PATCH] Add diagnostic items to MutexGuard and RwLock Guards I forgot to add the diagnostic to the actual types in `std` earlier. --- library/std/src/sync/mutex.rs | 1 + library/std/src/sync/rwlock.rs | 2 ++ src/test/ui/lint/let_underscore/let_underscore_lock.stderr | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/library/std/src/sync/mutex.rs b/library/std/src/sync/mutex.rs index 3d8281fe593..d976725c276 100644 --- a/library/std/src/sync/mutex.rs +++ b/library/std/src/sync/mutex.rs @@ -193,6 +193,7 @@ unsafe impl Sync for Mutex {} and cause Futures to not implement `Send`"] #[stable(feature = "rust1", since = "1.0.0")] #[clippy::has_significant_drop] +#[cfg_attr(not(test), rustc_diagnostic_item = "MutexGuard")] pub struct MutexGuard<'a, T: ?Sized + 'a> { lock: &'a Mutex, poison: poison::Guard, diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index 4f1b4bedaab..e956f00a12f 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -100,6 +100,7 @@ unsafe impl Sync for RwLock {} and cause Futures to not implement `Send`"] #[stable(feature = "rust1", since = "1.0.0")] #[clippy::has_significant_drop] +#[cfg_attr(not(test), rustc_diagnostic_item = "RwLockReadGuard")] pub struct RwLockReadGuard<'a, T: ?Sized + 'a> { lock: &'a RwLock, } @@ -124,6 +125,7 @@ unsafe impl Sync for RwLockReadGuard<'_, T> {} and cause Future's to not implement `Send`"] #[stable(feature = "rust1", since = "1.0.0")] #[clippy::has_significant_drop] +#[cfg_attr(not(test), rustc_diagnostic_item = "RwLockWriteGuard")] pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> { lock: &'a RwLock, poison: poison::Guard, diff --git a/src/test/ui/lint/let_underscore/let_underscore_lock.stderr b/src/test/ui/lint/let_underscore/let_underscore_lock.stderr index b7e14e8c7b5..7ff42cb1524 100644 --- a/src/test/ui/lint/let_underscore/let_underscore_lock.stderr +++ b/src/test/ui/lint/let_underscore/let_underscore_lock.stderr @@ -1,5 +1,5 @@ error: non-binding let on a synchronization lock - --> $DIR/let_underscore_lock.rs:5:5 + --> $DIR/let_underscore_lock.rs:6:5 | LL | let _ = data.lock().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^