Skip to content

Commit c3a1291

Browse files
committed
Auto merge of #124895 - obeis:static-mut-hidden-ref, r=compiler-errors
Disallow hidden references to mutable static Closes #123060 Tracking: - rust-lang/rust#123758
2 parents ff3b2d0 + f9d2e9d commit c3a1291

13 files changed

+35
-0
lines changed

tests/pass-dep/concurrency/linux-futex.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//@only-target: linux
22
//@compile-flags: -Zmiri-disable-isolation
33

4+
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
5+
#![allow(static_mut_refs)]
6+
47
use std::mem::MaybeUninit;
58
use std::ptr::{self, addr_of};
69
use std::sync::atomic::AtomicI32;

tests/pass-dep/concurrency/tls_pthread_drop_order.rs

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
//! the fallback path in `guard::key::enable`, which uses a *single* pthread_key
66
//! to manage a thread-local list of dtors to call.
77
8+
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
9+
#![allow(static_mut_refs)]
10+
811
use std::mem;
912
use std::ptr;
1013

tests/pass-dep/libc/libc-eventfd.rs

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// test_race depends on a deterministic schedule.
33
//@compile-flags: -Zmiri-preemption-rate=0
44

5+
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
6+
#![allow(static_mut_refs)]
7+
58
use std::thread;
69

710
fn main() {

tests/pass-dep/libc/libc-pipe.rs

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ fn test_pipe_threaded() {
7272
thread2.join().unwrap();
7373
}
7474

75+
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
76+
#[allow(static_mut_refs)]
7577
fn test_race() {
7678
static mut VAL: u8 = 0;
7779
let mut fds = [-1, -1];

tests/pass-dep/libc/libc-socketpair.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
//@ignore-target: windows # No libc socketpair on Windows
22
// test_race depends on a deterministic schedule.
33
//@compile-flags: -Zmiri-preemption-rate=0
4+
5+
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
6+
#![allow(static_mut_refs)]
7+
48
use std::thread;
59
fn main() {
610
test_socketpair();

tests/pass/atomic.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
//@revisions: stack tree
22
//@[tree]compile-flags: -Zmiri-tree-borrows
33
//@compile-flags: -Zmiri-strict-provenance
4+
45
#![feature(strict_provenance, strict_provenance_atomic_ptr)]
6+
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
7+
#![allow(static_mut_refs)]
8+
59
use std::sync::atomic::{
610
compiler_fence, fence, AtomicBool, AtomicIsize, AtomicPtr, AtomicU64, Ordering::*,
711
};

tests/pass/drop_on_array_elements.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(static_mut_refs)]
2+
13
struct Bar(u16); // ZSTs are tested separately
24

35
static mut DROP_COUNT: usize = 0;

tests/pass/drop_on_fat_ptr_array_elements.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(static_mut_refs)]
2+
13
trait Foo {}
24

35
struct Bar;

tests/pass/drop_on_zst_array_elements.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(static_mut_refs)]
2+
13
struct Bar;
24

35
static mut DROP_COUNT: usize = 0;

tests/pass/drop_through_owned_slice.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(static_mut_refs)]
2+
13
struct Bar;
24

35
static mut DROP_COUNT: usize = 0;

tests/pass/static_memory_modification.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
2+
#![allow(static_mut_refs)]
3+
14
use std::sync::atomic::{AtomicUsize, Ordering};
25

36
static mut X: usize = 5;

tests/pass/static_mut.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
2+
#![allow(static_mut_refs)]
3+
14
use std::ptr::addr_of;
25

36
static mut FOO: i32 = 42;

tests/pass/tls/tls_static.rs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//! dereferencing the pointer on `t2` resolves to `t1`'s thread-local. In this
88
//! test, we also check that thread-locals act as per-thread statics.
99
10+
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
11+
#![allow(static_mut_refs)]
1012
#![feature(thread_local)]
1113

1214
use std::ptr::addr_of_mut;

0 commit comments

Comments
 (0)