mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Address review comments.
This commit is contained in:
@@ -84,8 +84,15 @@ unsafe fn get_or_init_slow(
|
||||
// access to self.value and may replace it.
|
||||
let mut old_value = unsafe { self.value.get().replace(MaybeUninit::new(v)) };
|
||||
match self.state.replace(State::Alive) {
|
||||
// If the variable is not being recursively initialized, register
|
||||
// the destructor. This might be a noop if the value does not need
|
||||
// destruction.
|
||||
State::Uninitialized => D::register_dtor(self),
|
||||
|
||||
// Recursive initialization, we only need to drop the old value
|
||||
// as we've already registered the destructor.
|
||||
State::Alive => unsafe { old_value.assume_init_drop() },
|
||||
|
||||
State::Destroyed(_) => unreachable!(),
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//@ run-pass
|
||||
#![allow(stable_features)]
|
||||
//@ needs-threads
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
Reference in New Issue
Block a user