Skip to content

Commit 1a766a8

Browse files
Rollup merge of #140056 - yuk1ty:fix-static-mut-error-message, r=jieyouxu
Fix a wrong error message in 2024 edition Fixes #139952
2 parents 0134651 + bffb760 commit 1a766a8

22 files changed

+91
-93
lines changed

compiler/rustc_lint/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ lint_single_use_lifetime = lifetime parameter `{$ident}` only used once
757757
758758
lint_span_use_eq_ctxt = use `.eq_ctxt()` instead of `.ctxt() == .ctxt()`
759759
760-
lint_static_mut_refs_lint = creating a {$shared_label}reference to mutable static is discouraged
760+
lint_static_mut_refs_lint = creating a {$shared_label}reference to mutable static
761761
.label = {$shared_label}reference to mutable static
762762
.suggestion = use `&raw const` instead to create a raw pointer
763763
.suggestion_mut = use `&raw mut` instead to create a raw pointer

compiler/rustc_lint/src/static_mut_refs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ declare_lint! {
5151
/// This lint is "warn" by default on editions up to 2021, in 2024 is "deny".
5252
pub STATIC_MUT_REFS,
5353
Warn,
54-
"shared references or mutable references of mutable static is discouraged",
54+
"creating a shared reference to mutable static",
5555
@future_incompatible = FutureIncompatibleInfo {
5656
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024),
5757
reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>",

src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ LL | if result.is_ok() {
236236
LL | result.as_mut().unwrap();
237237
| ^^^^^^^^^^^^^^^^^^^^^^^^
238238

239-
error: creating a shared reference to mutable static is discouraged
239+
error: creating a shared reference to mutable static
240240
--> tests/ui/checked_unwrap/simple_conditionals.rs:183:12
241241
|
242242
LL | if X.is_some() {

tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl Foo {
1717
fn main() {
1818
unsafe {
1919
let sfoo: *mut Foo = &mut SFOO;
20-
//~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
20+
//~^ WARN mutable reference to mutable static [static_mut_refs]
2121
let x = (*sfoo).x();
2222
(*sfoo).x[1] += 1;
2323
*x += 1;

tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
warning: creating a mutable reference to mutable static is discouraged
1+
warning: creating a mutable reference to mutable static
22
--> $DIR/borrowck-unsafe-static-mutable-borrows.rs:19:30
33
|
44
LL | let sfoo: *mut Foo = &mut SFOO;

tests/ui/consts/const_let_assign2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static mut BB: AA = AA::new();
1616

1717
fn main() {
1818
let ptr = unsafe { &mut BB };
19-
//~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
19+
//~^ WARN mutable reference to mutable static [static_mut_refs]
2020
for a in ptr.data.iter() {
2121
println!("{}", a);
2222
}

tests/ui/consts/const_let_assign2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
warning: creating a mutable reference to mutable static is discouraged
1+
warning: creating a mutable reference to mutable static
22
--> $DIR/const_let_assign2.rs:18:24
33
|
44
LL | let ptr = unsafe { &mut BB };

tests/ui/issues/issue-39367.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn arena() -> &'static ArenaSet<Vec<u8>> {
2020

2121
static mut ONCE: Once = Once::new();
2222
ONCE.call_once(|| {
23-
//~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
23+
//~^ WARN creating a shared reference to mutable static [static_mut_refs]
2424
DATA = transmute
2525
::<Box<ArenaSet<Vec<u8>>>, *const ArenaSet<Vec<u8>>>
2626
(Box::new(__static_ref_initialize()));

tests/ui/issues/issue-39367.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
warning: creating a shared reference to mutable static is discouraged
1+
warning: creating a shared reference to mutable static
22
--> $DIR/issue-39367.rs:22:13
33
|
44
LL | / ONCE.call_once(|| {

tests/ui/lint/static-mut-refs.e2021.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
warning: creating a shared reference to mutable static is discouraged
1+
warning: creating a shared reference to mutable static
22
--> $DIR/static-mut-refs.rs:38:18
33
|
44
LL | let _y = &X;
@@ -12,7 +12,7 @@ help: use `&raw const` instead to create a raw pointer
1212
LL | let _y = &raw const X;
1313
| +++++++++
1414

15-
warning: creating a mutable reference to mutable static is discouraged
15+
warning: creating a mutable reference to mutable static
1616
--> $DIR/static-mut-refs.rs:42:18
1717
|
1818
LL | let _y = &mut X;
@@ -25,7 +25,7 @@ help: use `&raw mut` instead to create a raw pointer
2525
LL | let _y = &raw mut X;
2626
| +++
2727

28-
warning: creating a shared reference to mutable static is discouraged
28+
warning: creating a shared reference to mutable static
2929
--> $DIR/static-mut-refs.rs:50:22
3030
|
3131
LL | let ref _a = X;
@@ -34,7 +34,7 @@ LL | let ref _a = X;
3434
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
3535
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
3636

37-
warning: creating a shared reference to mutable static is discouraged
37+
warning: creating a shared reference to mutable static
3838
--> $DIR/static-mut-refs.rs:54:25
3939
|
4040
LL | let (_b, _c) = (&X, &Y);
@@ -47,7 +47,7 @@ help: use `&raw const` instead to create a raw pointer
4747
LL | let (_b, _c) = (&raw const X, &Y);
4848
| +++++++++
4949

50-
warning: creating a shared reference to mutable static is discouraged
50+
warning: creating a shared reference to mutable static
5151
--> $DIR/static-mut-refs.rs:54:29
5252
|
5353
LL | let (_b, _c) = (&X, &Y);
@@ -60,7 +60,7 @@ help: use `&raw const` instead to create a raw pointer
6060
LL | let (_b, _c) = (&X, &raw const Y);
6161
| +++++++++
6262

63-
warning: creating a shared reference to mutable static is discouraged
63+
warning: creating a shared reference to mutable static
6464
--> $DIR/static-mut-refs.rs:60:13
6565
|
6666
LL | foo(&X);
@@ -73,7 +73,7 @@ help: use `&raw const` instead to create a raw pointer
7373
LL | foo(&raw const X);
7474
| +++++++++
7575

76-
warning: creating a shared reference to mutable static is discouraged
76+
warning: creating a shared reference to mutable static
7777
--> $DIR/static-mut-refs.rs:66:17
7878
|
7979
LL | let _ = Z.len();
@@ -82,7 +82,7 @@ LL | let _ = Z.len();
8282
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
8383
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
8484

85-
warning: creating a shared reference to mutable static is discouraged
85+
warning: creating a shared reference to mutable static
8686
--> $DIR/static-mut-refs.rs:72:33
8787
|
8888
LL | let _ = format!("{:?}", Z);
@@ -91,7 +91,7 @@ LL | let _ = format!("{:?}", Z);
9191
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
9292
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
9393

94-
warning: creating a shared reference to mutable static is discouraged
94+
warning: creating a shared reference to mutable static
9595
--> $DIR/static-mut-refs.rs:76:18
9696
|
9797
LL | let _v = &A.value;
@@ -104,7 +104,7 @@ help: use `&raw const` instead to create a raw pointer
104104
LL | let _v = &raw const A.value;
105105
| +++++++++
106106

107-
warning: creating a shared reference to mutable static is discouraged
107+
warning: creating a shared reference to mutable static
108108
--> $DIR/static-mut-refs.rs:80:18
109109
|
110110
LL | let _s = &A.s.value;
@@ -117,7 +117,7 @@ help: use `&raw const` instead to create a raw pointer
117117
LL | let _s = &raw const A.s.value;
118118
| +++++++++
119119

120-
warning: creating a shared reference to mutable static is discouraged
120+
warning: creating a shared reference to mutable static
121121
--> $DIR/static-mut-refs.rs:84:22
122122
|
123123
LL | let ref _v = A.value;
@@ -126,7 +126,7 @@ LL | let ref _v = A.value;
126126
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
127127
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
128128

129-
warning: creating a mutable reference to mutable static is discouraged
129+
warning: creating a mutable reference to mutable static
130130
--> $DIR/static-mut-refs.rs:14:14
131131
|
132132
LL | &mut ($x.0)

0 commit comments

Comments
 (0)