You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
warning: shared reference of mutable static is discouraged
2
+
--> $DIR/static-mut-foreign.rs:35:18
3
+
|
4
+
LL | static_bound(&rust_dbg_static_mut);
5
+
| ^^^^^^^^^^^^^^^^^^^^ shared reference of mutable static
6
+
|
7
+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
8
+
= note: reference of mutable static is a hard error from 2024 edition
9
+
= note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
10
+
= note: `#[warn(static_mut_ref)]` on by default
11
+
help: shared references are dangerous since if there's any kind of mutation of that static while the reference lives, that's UB; use `addr_of!` instead to create a raw pointer
12
+
|
13
+
LL | static_bound(addr_of!(rust_dbg_static_mut));
14
+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
+
16
+
warning: mutable reference of mutable static is discouraged
17
+
--> $DIR/static-mut-foreign.rs:37:22
18
+
|
19
+
LL | static_bound_set(&mut rust_dbg_static_mut);
20
+
| ^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference of mutable static
21
+
|
22
+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
23
+
= note: reference of mutable static is a hard error from 2024 edition
24
+
= note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
25
+
help: mutable references are dangerous since if there's any other pointer or reference used for that static while the reference lives, that's UB; use `addr_of_mut!` instead to create a raw pointer
Copy file name to clipboardExpand all lines: tests/ui/borrowck/borrowck-access-permissions.stderr
+24-9
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,20 @@
1
+
warning: mutable reference of mutable static is discouraged
2
+
--> $DIR/borrowck-access-permissions.rs:18:23
3
+
|
4
+
LL | let _y2 = &mut static_x_mut;
5
+
| ^^^^^^^^^^^^^^^^^ mutable reference of mutable static
6
+
|
7
+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
8
+
= note: reference of mutable static is a hard error from 2024 edition
9
+
= note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
10
+
= note: `#[warn(static_mut_ref)]` on by default
11
+
help: mutable references are dangerous since if there's any other pointer or reference used for that static while the reference lives, that's UB; use `addr_of_mut!` instead to create a raw pointer
12
+
|
13
+
LL | let _y2 = addr_of_mut!(static_x_mut);
14
+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
15
+
1
16
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
2
-
--> $DIR/borrowck-access-permissions.rs:9:19
17
+
--> $DIR/borrowck-access-permissions.rs:10:19
3
18
|
4
19
LL | let _y1 = &mut x;
5
20
| ^^^^^^ cannot borrow as mutable
@@ -10,13 +25,13 @@ LL | let mut x = 1;
10
25
| +++
11
26
12
27
error[E0596]: cannot borrow immutable static item `static_x` as mutable
13
-
--> $DIR/borrowck-access-permissions.rs:14:19
28
+
--> $DIR/borrowck-access-permissions.rs:16:19
14
29
|
15
30
LL | let _y1 = &mut static_x;
16
31
| ^^^^^^^^^^^^^ cannot borrow as mutable
17
32
18
33
error[E0596]: cannot borrow `*box_x` as mutable, as `box_x` is not declared as mutable
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
8
+
= note: reference of mutable static is a hard error from 2024 edition
9
+
= note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
10
+
= note: `#[warn(static_mut_ref)]` on by default
11
+
help: mutable references are dangerous since if there's any other pointer or reference used for that static while the reference lives, that's UB; use `addr_of_mut!` instead to create a raw pointer
0 commit comments