mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 05:51:58 +00:00
library: Call it really_init_mut to avoid name collisions
This commit is contained in:
parent
d9cdb71497
commit
f22797d3db
@ -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> {
|
||||
@ -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(),
|
||||
}
|
||||
}
|
||||
|
@ -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]
|
||||
@ -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) },
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user