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