Skip to content

Commit

Permalink
library: Call it really_init_mut to avoid name collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
workingjubilee committed Sep 18, 2024
1 parent d9cdb71 commit f22797d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions library/core/src/cell/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl<T, F: FnOnce() -> T> LazyCell<T, F> {
#[cold]
/// # Safety
/// May only be called when the state is `Uninit`.
unsafe fn really_init<T, F: FnOnce() -> T>(state: &mut State<T, F>) -> &mut T {
unsafe fn really_init_mut<T, F: FnOnce() -> T>(state: &mut State<T, F>) -> &mut T {
// INVARIANT: Always valid, but the value may not be dropped.
struct PoisonOnPanic<T, F>(*mut State<T, F>);
impl<T, F> Drop for PoisonOnPanic<T, F> {
Expand Down Expand Up @@ -179,7 +179,7 @@ impl<T, F: FnOnce() -> T> LazyCell<T, F> {
match state {
State::Init(data) => data,
// SAFETY: `state` is `Uninit`.
State::Uninit(_) => unsafe { really_init(state) },
State::Uninit(_) => unsafe { really_init_mut(state) },
State::Poisoned => panic_poisoned(),
}
}
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sync/lazy_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl<T, F: FnOnce() -> T> LazyLock<T, F> {
#[cold]
/// # Safety
/// May only be called when the state is `Incomplete`.
unsafe fn really_init<T, F: FnOnce() -> T>(this: &mut LazyLock<T, F>) -> &mut T {
unsafe fn really_init_mut<T, F: FnOnce() -> T>(this: &mut LazyLock<T, F>) -> &mut T {
struct PoisonOnPanic<'a, T, F>(&'a mut LazyLock<T, F>);
impl<T, F> Drop for PoisonOnPanic<'_, T, F> {
#[inline]
Expand Down Expand Up @@ -184,7 +184,7 @@ impl<T, F: FnOnce() -> T> LazyLock<T, F> {
// SAFETY: The `Once` states we completed the initialization.
ExclusiveState::Complete => unsafe { &mut this.data.get_mut().value },
// SAFETY: The state is `Incomplete`.
ExclusiveState::Incomplete => unsafe { really_init(this) },
ExclusiveState::Incomplete => unsafe { really_init_mut(this) },
}
}

Expand Down

0 comments on commit f22797d

Please sign in to comment.