diff --git a/library/std/src/sync/nonpoison/mutex.rs b/library/std/src/sync/nonpoison/mutex.rs index ca3a0ada088af..a4ba86e38516c 100644 --- a/library/std/src/sync/nonpoison/mutex.rs +++ b/library/std/src/sync/nonpoison/mutex.rs @@ -277,7 +277,7 @@ impl Mutex { /// /// thread::spawn(move || { /// *c_mutex.lock() = 10; - /// }).join().expect("thread::spawn failed"); + /// }).join().expect("`thread::spawn` should not fail"); /// assert_eq!(*mutex.lock(), 10); /// ``` #[unstable(feature = "nonpoison_mutex", issue = "134645")] @@ -316,7 +316,7 @@ impl Mutex { /// } else { /// println!("try_lock failed"); /// } - /// }).join().expect("thread::spawn failed"); + /// }).join().expect("`thread::spawn` should not fail"); /// assert_eq!(*mutex.lock().unwrap(), 10); /// ``` #[unstable(feature = "nonpoison_mutex", issue = "134645")] diff --git a/library/std/src/sync/poison/mutex.rs b/library/std/src/sync/poison/mutex.rs index 6eccd8a875edd..42c5fcf3e27c0 100644 --- a/library/std/src/sync/poison/mutex.rs +++ b/library/std/src/sync/poison/mutex.rs @@ -68,7 +68,7 @@ use crate::sys::sync as sys; /// } /// /// pub fn replace_with(&self, f: impl FnOnce(T) -> T) { -/// let ptr = self.data.lock().expect("poisoned"); +/// let ptr = self.data.lock().expect("`Mutex` should not be poisoned"); /// // While `f` is running, the data is moved out of `*ptr`. If `f` /// // panics, `*ptr` keeps pointing at a dropped value. The intention /// // is that this will poison the mutex, so the following calls to @@ -216,7 +216,7 @@ use crate::sys::sync as sys; /// threads.into_iter().for_each(|thread| { /// thread /// .join() -/// .expect("The thread creating or execution failed !") +/// .expect("Thread creation or execution should not fail") /// }); /// /// assert_eq!(*res_mutex.lock().unwrap(), 800); @@ -482,7 +482,7 @@ impl Mutex { /// /// thread::spawn(move || { /// *c_mutex.lock().unwrap() = 10; - /// }).join().expect("thread::spawn failed"); + /// }).join().expect("`thread::spawn` should not fail"); /// assert_eq!(*mutex.lock().unwrap(), 10); /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -531,7 +531,7 @@ impl Mutex { /// } else { /// println!("try_lock failed"); /// } - /// }).join().expect("thread::spawn failed"); + /// }).join().expect("`thread::spawn` should not fail"); /// assert_eq!(*mutex.lock().unwrap(), 10); /// ``` #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/std/src/sync/reentrant_lock.rs b/library/std/src/sync/reentrant_lock.rs index fd8a2507f68fd..faa1bba1f5389 100644 --- a/library/std/src/sync/reentrant_lock.rs +++ b/library/std/src/sync/reentrant_lock.rs @@ -275,7 +275,7 @@ impl ReentrantLock { /// /// thread::spawn(move || { /// c_lock.lock().set(10); - /// }).join().expect("thread::spawn failed"); + /// }).join().expect("`thread::spawn` should not fail"); /// assert_eq!(lock.lock().get(), 10); /// ``` pub fn lock(&self) -> ReentrantLockGuard<'_, T> {