diff --git a/Cargo.lock b/Cargo.lock index 3ea955d74f7f..6d9d68d8a8fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4682,9 +4682,9 @@ dependencies = [ [[package]] name = "scoped-tls" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" [[package]] name = "scopeguard" diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index 3b5132a10ae5..f0f22c33a246 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -1569,6 +1569,11 @@ who = "Mike Hommey " criteria = "safe-to-deploy" delta = "1.0.10 -> 1.0.11" +[[audits.scoped-tls]] +who = "Mike Hommey " +criteria = "safe-to-run" +delta = "1.0.0 -> 1.0.1" + [[audits.scroll]] who = "Jan-Erik Rediger " criteria = "safe-to-deploy" diff --git a/third_party/rust/scoped-tls/.cargo-checksum.json b/third_party/rust/scoped-tls/.cargo-checksum.json index a82babc4a514..ab1c98519d55 100644 --- a/third_party/rust/scoped-tls/.cargo-checksum.json +++ b/third_party/rust/scoped-tls/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"9b7a3fdb45ac3847229254d53222ed393d5e5426e7d126dc3a1adfeb35b8b438","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"5b42f802520064732b4097d9224cddffb6ad397536347bc996c95f433d893e85","appveyor.yml":"da991211b72fa6f231af7adb84c9fb72f5a9131d1c0a3d47b8ceffe5a82c8542","src/lib.rs":"03cafc877737e72e8bc6fed874c5b1154ec7a0579c5f875f1da66df54b642864"},"package":"ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"} \ No newline at end of file +{"files":{"Cargo.toml":"34fd266d7e61276cf49fb2a9ea9887331ef4e72595fed99b7d8735c86cd13631","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"0cf015ca6dd078c0f0e607508a4190c0a1328990069e6303c4709530960aab08","src/lib.rs":"ca804e29dde7dc843ab24f7f70c694eb43fac7c62194d85a58c8062caa0a84f4"},"package":"e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"} \ No newline at end of file diff --git a/third_party/rust/scoped-tls/Cargo.toml b/third_party/rust/scoped-tls/Cargo.toml index 70c386117beb..08ec7b613469 100644 --- a/third_party/rust/scoped-tls/Cargo.toml +++ b/third_party/rust/scoped-tls/Cargo.toml @@ -3,18 +3,22 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g. crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] +rust-version = "1.59" name = "scoped-tls" -version = "1.0.0" +version = "1.0.1" authors = ["Alex Crichton "] -description = "Library implementation of the standard library's old `scoped_thread_local!`\nmacro for providing scoped access to thread local storage (TLS) so any type can\nbe stored into TLS.\n" +description = """ +Library implementation of the standard library's old `scoped_thread_local!` +macro for providing scoped access to thread local storage (TLS) so any type can +be stored into TLS. +""" homepage = "https://github.com/alexcrichton/scoped-tls" documentation = "https://docs.rs/scoped-tls" readme = "README.md" diff --git a/third_party/rust/scoped-tls/README.md b/third_party/rust/scoped-tls/README.md index 88bd62401085..36e6480e2c69 100644 --- a/third_party/rust/scoped-tls/README.md +++ b/third_party/rust/scoped-tls/README.md @@ -11,7 +11,7 @@ as a library implementation on crates.io. ```toml # Cargo.toml [dependencies] -scoped-tls = "0.1" +scoped-tls = "1.0" ``` # License diff --git a/third_party/rust/scoped-tls/appveyor.yml b/third_party/rust/scoped-tls/appveyor.yml deleted file mode 100644 index 6a1b8dc19c03..000000000000 --- a/third_party/rust/scoped-tls/appveyor.yml +++ /dev/null @@ -1,17 +0,0 @@ -environment: - matrix: - - TARGET: x86_64-pc-windows-msvc - - TARGET: i686-pc-windows-msvc - - TARGET: i686-pc-windows-gnu -install: - - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin - - SET PATH=%PATH%;C:\MinGW\bin - - rustc -V - - cargo -V - -build: false - -test_script: - - cargo test --verbose diff --git a/third_party/rust/scoped-tls/src/lib.rs b/third_party/rust/scoped-tls/src/lib.rs index 6fbcf11e391e..d4567c2bcbd7 100644 --- a/third_party/rust/scoped-tls/src/lib.rs +++ b/third_party/rust/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()) } }