Skip to content

Commit 6457f4d

Browse files
committed
Address review comments.
1 parent d0d5d19 commit 6457f4d

File tree

1 file changed

+7
-0
lines changed
  • std/src/sys/thread_local/native

1 file changed

+7
-0
lines changed

std/src/sys/thread_local/native/lazy.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,15 @@ where
8484
// access to self.value and may replace it.
8585
let mut old_value = unsafe { self.value.get().replace(MaybeUninit::new(v)) };
8686
match self.state.replace(State::Alive) {
87+
// If the variable is not being recursively initialized, register
88+
// the destructor. This might be a noop if the value does not need
89+
// destruction.
8790
State::Uninitialized => D::register_dtor(self),
91+
92+
// Recursive initialization, we only need to drop the old value
93+
// as we've already registered the destructor.
8894
State::Alive => unsafe { old_value.assume_init_drop() },
95+
8996
State::Destroyed(_) => unreachable!(),
9097
}
9198

0 commit comments

Comments
 (0)