about summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-05-09 17:26:38 +0800
committerkennytm <kennytm@gmail.com>2018-05-09 20:29:46 +0800
commit4924fea2026c0360cd57106ee6f1199924ad50e1 (patch)
tree1a6ea1fe9ae65414a279c97bbd289c141e59ffed /src/libstd/sync
parent4c3ab33f3a94b7ce21a28658d403e27a81ef042d (diff)
parenta72a0801bdab22d7c0167f67d1148276ea874d2e (diff)
downloadrust-4924fea2026c0360cd57106ee6f1199924ad50e1.tar.gz
rust-4924fea2026c0360cd57106ee6f1199924ad50e1.zip
Rollup merge of #50511 - Manishearth:must-use, r=QuietMisdreavus
Add some explanations for #[must_use]

`#[must_use]` can be given a string argument which is shown whilst warning for things.

We should add a string argument to most of the user-exposed ones.

I added these for everything but the operators, mostly because I'm not sure what to write there or if we need anything there.
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/mutex.rs2
-rw-r--r--src/libstd/sync/rwlock.rs4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs
index 3b4904c98e8..f3503b0b3a6 100644
--- a/src/libstd/sync/mutex.rs
+++ b/src/libstd/sync/mutex.rs
@@ -150,7 +150,7 @@ unsafe impl<T: ?Sized + Send> Sync for Mutex<T> { }
 /// [`lock`]: struct.Mutex.html#method.lock
 /// [`try_lock`]: struct.Mutex.html#method.try_lock
 /// [`Mutex`]: struct.Mutex.html
-#[must_use]
+#[must_use = "if unused the Mutex will immediately unlock"]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct MutexGuard<'a, T: ?Sized + 'a> {
     // funny underscores due to how Deref/DerefMut currently work (they
diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs
index f7fdedc0d21..e3db60cff84 100644
--- a/src/libstd/sync/rwlock.rs
+++ b/src/libstd/sync/rwlock.rs
@@ -94,7 +94,7 @@ unsafe impl<T: ?Sized + Send + Sync> Sync for RwLock<T> {}
 /// [`read`]: struct.RwLock.html#method.read
 /// [`try_read`]: struct.RwLock.html#method.try_read
 /// [`RwLock`]: struct.RwLock.html
-#[must_use]
+#[must_use = "if unused the RwLock will immediately unlock"]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
     __lock: &'a RwLock<T>,
@@ -115,7 +115,7 @@ unsafe impl<'a, T: ?Sized + Sync> Sync for RwLockReadGuard<'a, T> {}
 /// [`write`]: struct.RwLock.html#method.write
 /// [`try_write`]: struct.RwLock.html#method.try_write
 /// [`RwLock`]: struct.RwLock.html
-#[must_use]
+#[must_use = "if unused the RwLock will immediately unlock"]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> {
     __lock: &'a RwLock<T>,