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
@@ -375,19 +375,24 @@ hir_analysis_start_not_target_feature = `#[start]` function is not allowed to ha
375
375
hir_analysis_start_not_track_caller = `#[start]` function is not allowed to be `#[track_caller]`
376
376
.label = `#[start]` function is not allowed to be `#[track_caller]`
377
377
378
-
hir_analysis_static_mut_ref = reference of mutable static is disallowed
379
-
.label = reference of mutable static
380
-
.note = mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
381
-
.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
382
-
.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
383
-
384
-
hir_analysis_static_mut_ref_lint = {$shared}reference of mutable static is discouraged
385
-
.label = shared reference of mutable static
386
-
.label_mut = mutable reference of mutable static
387
-
.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
388
-
.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
389
-
.note = reference of mutable static is a hard error from 2024 edition
390
-
.why_note = mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
378
+
hir_analysis_static_mut_ref = creating a {$shared} reference to a mutable static
379
+
.label = {$shared} reference to mutable static
380
+
.note = {$shared->
381
+
[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
382
+
*[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
383
+
}
384
+
.suggestion = use `addr_of!` instead to create a raw pointer
385
+
.suggestion_mut = use `addr_of_mut!` instead to create a raw pointer
386
+
387
+
hir_analysis_static_mut_refs_lint = creating a {$shared} reference to mutable static is discouraged
388
+
.label = {$shared} reference to mutable static
389
+
.suggestion = use `addr_of!` instead to create a raw pointer
390
+
.suggestion_mut = use `addr_of_mut!` instead to create a raw pointer
391
+
.note = this will be a hard error in the 2024 edition
392
+
.why_note = {$shared->
393
+
[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
394
+
*[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
395
+
}
391
396
392
397
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