Skip to content

Commit 7d2fd98

Browse files
committed
Update test
1 parent d97f0a1 commit 7d2fd98

30 files changed

+313
-15
lines changed

compiler/rustc_driver_impl/src/signal_handler.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ macro raw_errln($tokens:tt) {
3434
}
3535

3636
/// Signal handler installed for SIGSEGV
37+
// FIXME(obeis): Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
38+
#[allow(static_mut_refs)]
3739
extern "C" fn print_stack_trace(_: libc::c_int) {
3840
const MAX_FRAMES: usize = 256;
3941
// Reserve data segment so we don't have to malloc in a signal handler, which might fail

library/alloc/tests/vec.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,8 @@ fn test_from_iter_specialization_panic_during_iteration_drops() {
12851285

12861286
#[test]
12871287
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
1288+
// FIXME(obeis): Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
1289+
#[cfg_attr(not(bootstrap), allow(static_mut_refs))]
12881290
fn test_from_iter_specialization_panic_during_drop_doesnt_leak() {
12891291
static mut DROP_COUNTER_OLD: [usize; 5] = [0; 5];
12901292
static mut DROP_COUNTER_NEW: [usize; 2] = [0; 2];

library/core/tests/atomic.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ fn static_init() {
228228
}
229229

230230
#[test]
231+
// FIXME(obeis): Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
232+
#[cfg_attr(not(bootstrap), allow(static_mut_refs))]
231233
fn atomic_access_bool() {
232234
static mut ATOMIC: AtomicBool = AtomicBool::new(false);
233235

src/tools/tidy/src/issues.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,6 @@ ui/issues/issue-17068.rs
16521652
ui/issues/issue-17121.rs
16531653
ui/issues/issue-17216.rs
16541654
ui/issues/issue-17252.rs
1655-
ui/issues/issue-17302.rs
16561655
ui/issues/issue-17322.rs
16571656
ui/issues/issue-17336.rs
16581657
ui/issues/issue-17337.rs

tests/ui/async-await/issues/issue-67611-static-mut-refs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fn is_send_sync<T: Send + Sync>(_: T) {}
99

1010
async fn fun() {
1111
let u = unsafe { A[async { 1 }.await] };
12+
//~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
1213
unsafe {
1314
match A {
1415
i if async { true }.await => (),
@@ -21,6 +22,7 @@ async fn fun() {
2122
fn main() {
2223
let index_block = async {
2324
let u = unsafe { A[async { 1 }.await] };
25+
//~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
2426
};
2527
let match_block = async {
2628
unsafe {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
warning: creating a shared reference to mutable static is discouraged
2+
--> $DIR/issue-67611-static-mut-refs.rs:11:22
3+
|
4+
LL | let u = unsafe { A[async { 1 }.await] };
5+
| ^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
6+
|
7+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
8+
= note: this will be a hard error in the 2024 edition
9+
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
10+
= note: `#[warn(static_mut_refs)]` on by default
11+
12+
warning: creating a shared reference to mutable static is discouraged
13+
--> $DIR/issue-67611-static-mut-refs.rs:24:26
14+
|
15+
LL | let u = unsafe { A[async { 1 }.await] };
16+
| ^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
17+
|
18+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
19+
= note: this will be a hard error in the 2024 edition
20+
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
21+
22+
warning: 2 warnings emitted
23+

tests/ui/binding/order-drop-with-match.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ impl Drop for A {
1414
fn drop(&mut self) {
1515
unsafe {
1616
ORDER[INDEX] = 1;
17+
//~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
1718
INDEX = INDEX + 1;
1819
}
1920
}
@@ -24,6 +25,7 @@ impl Drop for B {
2425
fn drop(&mut self) {
2526
unsafe {
2627
ORDER[INDEX] = 2;
28+
//~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
2729
INDEX = INDEX + 1;
2830
}
2931
}
@@ -34,6 +36,7 @@ impl Drop for C {
3436
fn drop(&mut self) {
3537
unsafe {
3638
ORDER[INDEX] = 3;
39+
//~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
3740
INDEX = INDEX + 1;
3841
}
3942
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
warning: creating a shared reference to mutable static is discouraged
2+
--> $DIR/order-drop-with-match.rs:16:13
3+
|
4+
LL | ORDER[INDEX] = 1;
5+
| ^^^^^^^^^^^^ shared reference to mutable static
6+
|
7+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
8+
= note: this will be a hard error in the 2024 edition
9+
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
10+
= note: `#[warn(static_mut_refs)]` on by default
11+
12+
warning: creating a shared reference to mutable static is discouraged
13+
--> $DIR/order-drop-with-match.rs:27:13
14+
|
15+
LL | ORDER[INDEX] = 2;
16+
| ^^^^^^^^^^^^ shared reference to mutable static
17+
|
18+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
19+
= note: this will be a hard error in the 2024 edition
20+
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
21+
22+
warning: creating a shared reference to mutable static is discouraged
23+
--> $DIR/order-drop-with-match.rs:38:13
24+
|
25+
LL | ORDER[INDEX] = 3;
26+
| ^^^^^^^^^^^^ shared reference to mutable static
27+
|
28+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
29+
= note: this will be a hard error in the 2024 edition
30+
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
31+
32+
warning: 3 warnings emitted
33+

tests/ui/consts/static-mut-refs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ static mut INT_RAW: *mut isize = &mut 1isize as *mut _;
1717
pub fn main() {
1818
unsafe {
1919
TEST[0] += 1;
20+
//~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
2021
assert_eq!(TEST[0], 2);
22+
//~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
2123
*INT_RAW += 1;
2224
assert_eq!(*INT_RAW, 2);
2325
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
warning: creating a shared reference to mutable static is discouraged
2+
--> $DIR/static-mut-refs.rs:19:9
3+
|
4+
LL | TEST[0] += 1;
5+
| ^^^^^^^ shared reference to mutable static
6+
|
7+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
8+
= note: this will be a hard error in the 2024 edition
9+
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
10+
= note: `#[warn(static_mut_refs)]` on by default
11+
12+
warning: creating a shared reference to mutable static is discouraged
13+
--> $DIR/static-mut-refs.rs:21:20
14+
|
15+
LL | assert_eq!(TEST[0], 2);
16+
| ^^^^^^^ shared reference to mutable static
17+
|
18+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
19+
= note: this will be a hard error in the 2024 edition
20+
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
21+
22+
warning: 2 warnings emitted
23+

0 commit comments

Comments
 (0)