From 06eb782c4e727c33d8548a791998a0a2cbedceae Mon Sep 17 00:00:00 2001 From: Connor Tsui Date: Fri, 22 Aug 2025 14:58:42 -0400 Subject: modify `LazyLock` poison panic message Fixes an issue where if the underlying `Once` panics because it is poisoned, the panic displays the wrong message. Signed-off-by: Connor Tsui --- library/std/src/sync/lazy_lock.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'library/std/src') diff --git a/library/std/src/sync/lazy_lock.rs b/library/std/src/sync/lazy_lock.rs index a40e29a772a..3231125f7a1 100644 --- a/library/std/src/sync/lazy_lock.rs +++ b/library/std/src/sync/lazy_lock.rs @@ -244,7 +244,11 @@ impl T> LazyLock { #[inline] #[stable(feature = "lazy_cell", since = "1.80.0")] pub fn force(this: &LazyLock) -> &T { - this.once.call_once(|| { + this.once.call_once_force(|state| { + if state.is_poisoned() { + panic_poisoned(); + } + // SAFETY: `call_once` only runs this closure once, ever. let data = unsafe { &mut *this.data.get() }; let f = unsafe { ManuallyDrop::take(&mut data.f) }; @@ -257,8 +261,7 @@ impl T> LazyLock { // * the closure was called and initialized `value`. // * the closure was called and panicked, so this point is never reached. // * the closure was not called, but a previous call initialized `value`. - // * the closure was not called because the Once is poisoned, so this point - // is never reached. + // * the closure was not called because the Once is poisoned, which we handled above. // So `value` has definitely been initialized and will not be modified again. unsafe { &*(*this.data.get()).value } } -- cgit 1.4.1-3-g733a5 From 399f5e244cfb77b2c3addaeeae6007df5618bb9d Mon Sep 17 00:00:00 2001 From: Ada Alakbarova <58857108+ada4a@users.noreply.github.com> Date: Sat, 23 Aug 2025 23:05:30 +0200 Subject: std/src/lib.rs: mention "search button" instead of "search bar" --- library/std/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'library/std/src') diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index ab417b6c72f..f0de03c9a28 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -15,7 +15,7 @@ //! //! If you already know the name of what you are looking for, the fastest way to //! find it is to use the search -//! bar at the top of the page. +//! button at the top of the page. //! //! Otherwise, you may want to jump to one of these useful sections: //! -- cgit 1.4.1-3-g733a5