Skip to content

Commit 43f21a6

Browse files
thread_local: split refs to fields of Key
1 parent 538ddb0 commit 43f21a6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

library/std/src/sys/thread_local/fast_local.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::lazy::LazyKeyInner;
22
use crate::cell::Cell;
33
use crate::sys::thread_local_dtor::register_dtor;
4-
use crate::{fmt, mem, panic};
4+
use crate::{fmt, mem, panic, ptr};
55

66
#[doc(hidden)]
77
#[allow_internal_unstable(thread_local_internals, cfg_target_thread_local, thread_local)]
@@ -237,8 +237,9 @@ unsafe extern "C" fn destroy_value<T>(ptr: *mut u8) {
237237
// Wrap the call in a catch to ensure unwinding is caught in the event
238238
// a panic takes place in a destructor.
239239
if let Err(_) = panic::catch_unwind(panic::AssertUnwindSafe(|| unsafe {
240-
let value = (*ptr).inner.take();
241-
(*ptr).dtor_state.set(DtorState::RunningOrHasRun);
240+
let Key { inner, dtor_state } = &*ptr;
241+
let value = inner.take();
242+
dtor_state.set(DtorState::RunningOrHasRun);
242243
drop(value);
243244
})) {
244245
rtabort!("thread local panicked on drop");

0 commit comments

Comments
 (0)