From 84da2fc1d773e3c4f7fd4f5c23f77d9df98519be Mon Sep 17 00:00:00 2001 From: Obei Sideg Date: Sat, 24 Aug 2024 06:49:09 +0300 Subject: [PATCH] Update tests for hidden references to mutable static --- alloc/src/collections/linked_list/tests.rs | 3 +++ alloc/src/collections/vec_deque/tests.rs | 3 +++ alloc/tests/fmt.rs | 2 ++ alloc/tests/vec.rs | 5 +++++ alloc/tests/vec_deque.rs | 3 +++ core/tests/atomic.rs | 2 ++ panic_unwind/src/seh.rs | 2 ++ std/src/sync/mod.rs | 3 +++ std/src/sys/alloc/wasm.rs | 3 +++ std/src/thread/local/tests.rs | 3 +++ 10 files changed, 29 insertions(+) diff --git a/alloc/src/collections/linked_list/tests.rs b/alloc/src/collections/linked_list/tests.rs index 9b3c9ac5ce52e..c93e5813b1182 100644 --- a/alloc/src/collections/linked_list/tests.rs +++ b/alloc/src/collections/linked_list/tests.rs @@ -1,3 +1,6 @@ +// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +#![allow(static_mut_refs)] + use std::panic::{catch_unwind, AssertUnwindSafe}; use std::thread; diff --git a/alloc/src/collections/vec_deque/tests.rs b/alloc/src/collections/vec_deque/tests.rs index f8ce4ca97884e..c90679f179775 100644 --- a/alloc/src/collections/vec_deque/tests.rs +++ b/alloc/src/collections/vec_deque/tests.rs @@ -1,3 +1,6 @@ +// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +#![allow(static_mut_refs)] + use core::iter::TrustedLen; use super::*; diff --git a/alloc/tests/fmt.rs b/alloc/tests/fmt.rs index ce24a40f4c051..c13074c53b73d 100644 --- a/alloc/tests/fmt.rs +++ b/alloc/tests/fmt.rs @@ -1,4 +1,6 @@ #![deny(warnings)] +// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +#![allow(static_mut_refs)] use std::cell::RefCell; use std::fmt::{self, Write}; diff --git a/alloc/tests/vec.rs b/alloc/tests/vec.rs index 3722fb06a6a8a..cf2ca4f0d657c 100644 --- a/alloc/tests/vec.rs +++ b/alloc/tests/vec.rs @@ -1,3 +1,6 @@ +// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +#![allow(static_mut_refs)] + use core::alloc::{Allocator, Layout}; use core::num::NonZero; use core::ptr::NonNull; @@ -1284,6 +1287,8 @@ fn test_from_iter_specialization_panic_during_iteration_drops() { #[test] #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] +// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +#[cfg_attr(not(bootstrap), allow(static_mut_refs))] fn test_from_iter_specialization_panic_during_drop_doesnt_leak() { static mut DROP_COUNTER_OLD: [usize; 5] = [0; 5]; static mut DROP_COUNTER_NEW: [usize; 2] = [0; 2]; diff --git a/alloc/tests/vec_deque.rs b/alloc/tests/vec_deque.rs index f32ba8d5aa461..0891d99fe666b 100644 --- a/alloc/tests/vec_deque.rs +++ b/alloc/tests/vec_deque.rs @@ -1,3 +1,6 @@ +// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +#![allow(static_mut_refs)] + use core::num::NonZero; use std::assert_matches::assert_matches; use std::collections::vec_deque::Drain; diff --git a/core/tests/atomic.rs b/core/tests/atomic.rs index 0d1c72a689291..2bdaeb3845a72 100644 --- a/core/tests/atomic.rs +++ b/core/tests/atomic.rs @@ -228,6 +228,8 @@ fn static_init() { } #[test] +// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +#[cfg_attr(not(bootstrap), allow(static_mut_refs))] fn atomic_access_bool() { static mut ATOMIC: AtomicBool = AtomicBool::new(false); diff --git a/panic_unwind/src/seh.rs b/panic_unwind/src/seh.rs index 070c11926f6e0..9e74a45a0e26e 100644 --- a/panic_unwind/src/seh.rs +++ b/panic_unwind/src/seh.rs @@ -291,6 +291,8 @@ cfg_if::cfg_if! { } } +// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +#[allow(static_mut_refs)] pub unsafe fn panic(data: Box) -> u32 { use core::intrinsics::atomic_store_seqcst; diff --git a/std/src/sync/mod.rs b/std/src/sync/mod.rs index d0ba8cc3b47df..70b419a1e33d1 100644 --- a/std/src/sync/mod.rs +++ b/std/src/sync/mod.rs @@ -9,6 +9,9 @@ //! Consider the following code, operating on some global static variables: //! //! ```rust +//! // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +//! #![allow(static_mut_refs)] +//! //! static mut A: u32 = 0; //! static mut B: u32 = 0; //! static mut C: u32 = 0; diff --git a/std/src/sys/alloc/wasm.rs b/std/src/sys/alloc/wasm.rs index ef9d753d7f86c..a308fafc68b15 100644 --- a/std/src/sys/alloc/wasm.rs +++ b/std/src/sys/alloc/wasm.rs @@ -16,6 +16,9 @@ //! The crate itself provides a global allocator which on wasm has no //! synchronization as there are no threads! +// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +#![allow(static_mut_refs)] + use crate::alloc::{GlobalAlloc, Layout, System}; static mut DLMALLOC: dlmalloc::Dlmalloc = dlmalloc::Dlmalloc::new(); diff --git a/std/src/thread/local/tests.rs b/std/src/thread/local/tests.rs index 25019b554bb6a..6abb9b85a2e29 100644 --- a/std/src/thread/local/tests.rs +++ b/std/src/thread/local/tests.rs @@ -103,6 +103,9 @@ fn smoke_dtor() { #[test] fn circular() { + // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint + #![allow(static_mut_refs)] + struct S1(&'static LocalKey>>, &'static LocalKey>>); struct S2(&'static LocalKey>>, &'static LocalKey>>); thread_local!(static K1: UnsafeCell> = UnsafeCell::new(None));