diff options
| author | Ralf Jung <post@ralfj.de> | 2025-08-25 07:39:19 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-25 07:39:19 +0000 |
| commit | dd801475461bc579232e82db7ea5573e8ebc6506 (patch) | |
| tree | 7ef1c1f5acf3a267d9a288380957f2a0ec69156b /library/std/src | |
| parent | 7f6f741ebaa6a396fee50b107a0dbfadc08d6a6c (diff) | |
| parent | ca89652f896dad0213e060ce9f6787c72e36a0e9 (diff) | |
Merge pull request #4542 from rust-lang/rustup-2025-08-25
Automatic Rustup
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/lib.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sync/lazy_lock.rs | 9 |
2 files changed, 7 insertions, 4 deletions
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 <a href="#" onclick="window.searchState.focus();">search -//! bar</a> at the top of the page. +//! button</a> at the top of the page. //! //! Otherwise, you may want to jump to one of these useful sections: //! 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, F: FnOnce() -> T> LazyLock<T, F> { #[inline] #[stable(feature = "lazy_cell", since = "1.80.0")] pub fn force(this: &LazyLock<T, F>) -> &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, F: FnOnce() -> T> LazyLock<T, F> { // * 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 } } |
