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
Copy file name to clipboardexpand all lines: compiler/rustc_hir_analysis/messages.ftl
+18-13
Original file line number
Diff line number
Diff line change
@@ -350,19 +350,24 @@ hir_analysis_start_not_target_feature = `#[start]` function is not allowed to ha
350
350
hir_analysis_start_not_track_caller = `#[start]` function is not allowed to be `#[track_caller]`
351
351
.label = `#[start]` function is not allowed to be `#[track_caller]`
352
352
353
-
hir_analysis_static_mut_ref = reference of mutable static is disallowed
354
-
.label = reference of mutable static
355
-
.note = mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
356
-
.suggestion = 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
357
-
.suggestion_mut = 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
358
-
359
-
hir_analysis_static_mut_ref_lint = {$shared}reference of mutable static is discouraged
360
-
.label = shared reference of mutable static
361
-
.label_mut = mutable reference of mutable static
362
-
.suggestion = 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
363
-
.suggestion_mut = 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
364
-
.note = reference of mutable static is a hard error from 2024 edition
365
-
.why_note = mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
353
+
hir_analysis_static_mut_ref = creating a {$shared} reference to a mutable static
354
+
.label = {$shared} reference to mutable static
355
+
.note = {$shared->
356
+
[shared] 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
357
+
*[mutable] this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
358
+
}
359
+
.suggestion = use `addr_of!` instead to create a raw pointer
360
+
.suggestion_mut = use `addr_of_mut!` instead to create a raw pointer
361
+
362
+
hir_analysis_static_mut_refs_lint = creating a {$shared} reference to mutable static is discouraged
363
+
.label = {$shared} reference to mutable static
364
+
.suggestion = use `addr_of!` instead to create a raw pointer
365
+
.suggestion_mut = use `addr_of_mut!` instead to create a raw pointer
366
+
.note = this will be a hard error in the 2024 edition
367
+
.why_note = {$shared->
368
+
[shared] 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
369
+
*[mutable] this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
370
+
}
366
371
367
372
hir_analysis_static_specialize = cannot specialize on `'static` lifetime
Copy file name to clipboardexpand all lines: tests/ui/abi/statics/static-mut-foreign.stderr
+11-11
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,28 @@
1
-
warning: shared reference of mutable static is discouraged
1
+
warning: creating a shared reference to mutable static is discouraged
2
2
--> $DIR/static-mut-foreign.rs:35:18
3
3
|
4
4
LL | static_bound(&rust_dbg_static_mut);
5
-
| ^^^^^^^^^^^^^^^^^^^^ shared reference of mutable static
5
+
| ^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
6
6
|
7
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
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
+
help: use `addr_of!` instead to create a raw pointer
12
12
|
13
13
LL | static_bound(addr_of!(rust_dbg_static_mut));
14
14
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
15
16
-
warning: mutable reference of mutable static is discouraged
16
+
warning: creating a mutable reference to mutable static is discouraged
17
17
--> $DIR/static-mut-foreign.rs:37:22
18
18
|
19
19
LL | static_bound_set(&mut rust_dbg_static_mut);
20
-
| ^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference of mutable static
20
+
| ^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference to mutable static
21
21
|
22
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
23
+
= note: this will be a hard error in the 2024 edition
24
+
= note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
25
+
help: use `addr_of_mut!` instead to create a raw pointer
0 commit comments