diff options
author | bjorn3 <bjorn3@users.noreply.github.com> | 2022-01-10 12:37:52 +0100 |
---|---|---|
committer | bjorn3 <bjorn3@users.noreply.github.com> | 2022-01-10 12:38:20 +0100 |
commit | fe198611515ec4d331baa813001c506f67e3c830 (patch) | |
tree | 15e1f7c789023fa27779e6b422caf0a22ef4f5da | |
parent | 6e4c3b15b6a5c5281e264b41f729eedae3b31887 (diff) | |
download | rust-const_tls_local_panic_count.tar.gz |
Add missing unsafe {} blocks in const thread_local! implconst_tls_local_panic_count
These are only necessary when the user of thread_local! uses
`#![deny(unsafe_op_in_unsafe_fn)]`
-rw-r--r-- | library/std/src/thread/local.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index 1d2f6e97680..cfc49b697e4 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -189,7 +189,11 @@ macro_rules! __thread_local_inner { #[cfg(all(target_family = "wasm", not(target_feature = "atomics")))] { static mut VAL: $t = INIT_EXPR; - Some(&VAL) + // FIXME: remove the #[allow(...)] marker when macros don't + // raise warning for missing/extraneous unsafe blocks anymore. + // See https://github.com/rust-lang/rust/issues/74838. + #[allow(unused_unsafe)] + unsafe { Some(&VAL) } } // If the platform has support for `#[thread_local]`, use it. @@ -205,7 +209,13 @@ macro_rules! __thread_local_inner { // just get going. if !$crate::mem::needs_drop::<$t>() { unsafe { - return Some(&VAL) + // FIXME: remove the #[allow(...)] marker when macros don't + // raise warning for missing/extraneous unsafe blocks anymore. + // See https://github.com/rust-lang/rust/issues/74838. + #[allow(unused_unsafe)] + unsafe { + return Some(&VAL); + } } } |