Skip to content

Commit 647dead

Browse files
committed
Tweak note condition
1 parent 071a3a6 commit 647dead

3 files changed

Lines changed: 2 additions & 4 deletions

File tree

compiler/rustc_lint/src/static_mut_refs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fn interior_mutability_suggestion(
214214

215215
let sugg =
216216
static_mutability_span(cx, def_id).map(|span| StaticMutRefsInteriorMutabilitySugg { span });
217-
(true, sugg)
217+
(sugg.is_none(), sugg)
218218
}
219219

220220
fn static_mutability_span(cx: &LateContext<'_>, def_id: DefId) -> Option<Span> {

tests/ui/issues/issue-39367.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ LL | | });
1010
| |______________^ shared reference to mutable static
1111
|
1212
= 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
13-
= help: use a type that relies on "interior mutability" instead; to read more on this, visit <https://doc.rust-lang.org/reference/interior-mutability.html>
1413
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
1514
= note: `#[warn(static_mut_refs)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
1615
help: this type already provides "interior mutability", so its binding doesn't need to be declared as mutable

tests/ui/lint/static-mut-refs-interior-mutability.stderr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ error: creating a shared reference to mutable static
44
LL | let _lock = unsafe { STDINOUT_MUTEX.lock().unwrap() };
55
| ^^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
66
|
7-
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
87
= 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
9-
= help: use a type that relies on "interior mutability" instead; to read more on this, visit <https://doc.rust-lang.org/reference/interior-mutability.html>
8+
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
109
= note: `#[deny(static_mut_refs)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
1110
help: this type already provides "interior mutability", so its binding doesn't need to be declared as mutable
1211
|

0 commit comments

Comments
 (0)