Skip to content

Commit

Permalink
Update tests for hidden references to mutable static
Browse files Browse the repository at this point in the history
  • Loading branch information
obeis committed Sep 13, 2024
1 parent 283ce13 commit 84da2fc
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions alloc/src/collections/linked_list/tests.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
3 changes: 3 additions & 0 deletions alloc/src/collections/vec_deque/tests.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down
2 changes: 2 additions & 0 deletions alloc/tests/fmt.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
5 changes: 5 additions & 0 deletions alloc/tests/vec.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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];
Expand Down
3 changes: 3 additions & 0 deletions alloc/tests/vec_deque.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 2 additions & 0 deletions core/tests/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions panic_unwind/src/seh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn Any + Send>) -> u32 {
use core::intrinsics::atomic_store_seqcst;

Expand Down
3 changes: 3 additions & 0 deletions std/src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions std/src/sys/alloc/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions std/src/thread/local/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<UnsafeCell<Option<S1>>>, &'static LocalKey<UnsafeCell<Option<S2>>>);
struct S2(&'static LocalKey<UnsafeCell<Option<S1>>>, &'static LocalKey<UnsafeCell<Option<S2>>>);
thread_local!(static K1: UnsafeCell<Option<S1>> = UnsafeCell::new(None));
Expand Down

0 comments on commit 84da2fc

Please sign in to comment.