From 2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:50 +0200 Subject: Merging upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/scoped-tls/src/lib.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'vendor/scoped-tls/src/lib.rs') diff --git a/vendor/scoped-tls/src/lib.rs b/vendor/scoped-tls/src/lib.rs index 6fbcf11e3..d4567c2bc 100644 --- a/vendor/scoped-tls/src/lib.rs +++ b/vendor/scoped-tls/src/lib.rs @@ -56,8 +56,8 @@ macro_rules! scoped_thread_local { $(#[$attrs])* $vis static $name: $crate::ScopedKey<$ty> = $crate::ScopedKey { inner: { - thread_local!(static FOO: ::std::cell::Cell = { - ::std::cell::Cell::new(0) + ::std::thread_local!(static FOO: ::std::cell::Cell<*const ()> = const { + ::std::cell::Cell::new(::std::ptr::null()) }); &FOO }, @@ -75,7 +75,7 @@ macro_rules! scoped_thread_local { /// their contents. pub struct ScopedKey { #[doc(hidden)] - pub inner: &'static LocalKey>, + pub inner: &'static LocalKey>, #[doc(hidden)] pub _marker: marker::PhantomData, } @@ -86,8 +86,8 @@ impl ScopedKey { /// Inserts a value into this scoped thread local storage slot for a /// duration of a closure. /// - /// While `cb` is running, the value `t` will be returned by `get` unless - /// this function is called recursively inside of `cb`. + /// While `f` is running, the value `t` will be returned by `get` unless + /// this function is called recursively inside of `f`. /// /// Upon return, this function will restore the previous value, if any /// was available. @@ -120,8 +120,8 @@ impl ScopedKey { where F: FnOnce() -> R { struct Reset { - key: &'static LocalKey>, - val: usize, + key: &'static LocalKey>, + val: *const (), } impl Drop for Reset { fn drop(&mut self) { @@ -130,7 +130,7 @@ impl ScopedKey { } let prev = self.inner.with(|c| { let prev = c.get(); - c.set(t as *const T as usize); + c.set(t as *const T as *const ()); prev }); let _reset = Reset { key: self.inner, val: prev }; @@ -165,8 +165,8 @@ impl ScopedKey { where F: FnOnce(&T) -> R { let val = self.inner.with(|c| c.get()); - assert!(val != 0, "cannot access a scoped thread local \ - variable without calling `set` first"); + assert!(!val.is_null(), "cannot access a scoped thread local \ + variable without calling `set` first"); unsafe { f(&*(val as *const T)) } @@ -174,7 +174,7 @@ impl ScopedKey { /// Test whether this TLS key has been `set` for the current thread. pub fn is_set(&'static self) -> bool { - self.inner.with(|c| c.get() != 0) + self.inner.with(|c| !c.get().is_null()) } } -- cgit v1.2.3