Skip to content

Commit ef8ab6d

Browse files
committed
Update UI test
1 parent d97f0a1 commit ef8ab6d

26 files changed

+307
-14
lines changed

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+

tests/ui/coroutine/static-mut-reference-across-yield.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn main() {
1010
unsafe {
1111
let gen_index = #[coroutine]
1212
static || {
13-
let u = A[{
13+
let u = A[{ //~ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
1414
yield;
1515
1
1616
}];
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
warning: creating a shared reference to mutable static is discouraged
2+
--> $DIR/static-mut-reference-across-yield.rs:13:21
3+
|
4+
LL | let u = A[{
5+
| _____________________^
6+
LL | | yield;
7+
LL | | 1
8+
LL | | }];
9+
| |______________^ shared reference to mutable static
10+
|
11+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
12+
= note: this will be a hard error in the 2024 edition
13+
= 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
14+
= note: `#[warn(static_mut_refs)]` on by default
15+
16+
warning: 1 warning emitted
17+

tests/ui/drop/issue-23338-ensure-param-drop-order.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub mod d {
8585
pub type Log<'a> = &'a RefCell<Vec<u32>>;
8686

8787
pub fn current_width() -> u32 {
88-
unsafe { max_width() - trails.leading_zeros() }
88+
unsafe { max_width() - trails.leading_zeros() } //~ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
8989
}
9090

9191
pub fn max_width() -> u32 {
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
warning: creating a shared reference to mutable static is discouraged
2+
--> $DIR/issue-23338-ensure-param-drop-order.rs:88:32
3+
|
4+
LL | ... unsafe { max_width() - trails.leading_zeros() }
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+
112
warning: creating a shared reference to mutable static is discouraged
213
--> $DIR/issue-23338-ensure-param-drop-order.rs:93:31
314
|
@@ -7,11 +18,10 @@ LL | (mem::size_of_val(&trails) * 8) as u32
718
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
819
= note: this will be a hard error in the 2024 edition
920
= 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
1121
help: use `addr_of!` instead to create a raw pointer
1222
|
1323
LL | (mem::size_of_val(addr_of!(trails)) * 8) as u32
1424
| ~~~~~~~~~~~~~~~~
1525

16-
warning: 1 warning emitted
26+
warning: 2 warnings emitted
1727

0 commit comments

Comments
 (0)