Skip to content

Commit 1419aef

Browse files
committed
workaround nll issue
Signed-off-by: tison <[email protected]>
1 parent 0790d34 commit 1419aef

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

library/std/src/sync/once_lock.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -384,18 +384,10 @@ impl<T> OnceLock<T> {
384384
where
385385
F: FnOnce() -> Result<T, E>,
386386
{
387-
// Fast path check
388-
// NOTE: We need to perform an acquire on the state in this method
389-
// in order to correctly synchronize `LazyLock::force`. This is
390-
// currently done by calling `self.get()`, which in turn calls
391-
// `self.is_initialized()`, which in turn performs the acquire.
392-
if let Some(value) = self.get_mut() {
393-
return Ok(value);
387+
if self.get().is_none() {
388+
self.initialize(f)?;
394389
}
395-
self.initialize(f)?;
396-
397390
debug_assert!(self.is_initialized());
398-
399391
// SAFETY: The inner value has been initialized
400392
Ok(unsafe { self.get_unchecked_mut() })
401393
}

0 commit comments

Comments
 (0)