Repository: rust-lang/rust
Pull request #140056: Fix a wrong error message in 2024 edition
Author: login: yuk1ty
Labels: name: T-compiler
description: Relevant to the compiler team, which will review and decide on the PR/issue.
name: S-waiting-on-bors
description: Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Created: 2025-04-20T01:44:34Z | Merged: 2025-04-28T20:29:17Z

<!-- homu-ignore:start -->
<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r? <reviewer name>
-->
<!-- homu-ignore:end -->

Fixes https://github.com/rust-lang/rust/issues/139952



Diff:
diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl
index 60c183bd56b1f..9025c41240bf7 100644
--- a/compiler/rustc_lint/messages.ftl
+++ b/compiler/rustc_lint/messages.ftl
@@ -757,7 +757,7 @@ lint_single_use_lifetime = lifetime parameter `{$ident}` only used once
 
 lint_span_use_eq_ctxt = use `.eq_ctxt()` instead of `.ctxt() == .ctxt()`
 
-lint_static_mut_refs_lint = creating a {$shared_label}reference to mutable static is discouraged
+lint_static_mut_refs_lint = creating a {$shared_label}reference to mutable static
     .label = {$shared_label}reference to mutable static
     .suggestion = use `&raw const` instead to create a raw pointer
     .suggestion_mut = use `&raw mut` instead to create a raw pointer
diff --git a/compiler/rustc_lint/src/static_mut_refs.rs b/compiler/rustc_lint/src/static_mut_refs.rs
index 50021157ddab7..4dda3c7951b87 100644
--- a/compiler/rustc_lint/src/static_mut_refs.rs
+++ b/compiler/rustc_lint/src/static_mut_refs.rs
@@ -51,7 +51,7 @@ declare_lint! {
     /// This lint is "warn" by default on editions up to 2021, in 2024 is "deny".
     pub STATIC_MUT_REFS,
     Warn,
-    "shared references or mutable references of mutable static is discouraged",
+    "creating a shared reference to mutable static",
     @future_incompatible = FutureIncompatibleInfo {
         reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024),
         reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>",
diff --git a/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr b/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr
index bdac1e42309d8..ad3c420270c14 100644
--- a/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr
+++ b/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr
@@ -236,7 +236,7 @@ LL |     if result.is_ok() {
 LL |         result.as_mut().unwrap();
    |         ^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: creating a shared reference to mutable static is discouraged
+error: creating a shared reference to mutable static
   --> tests/ui/checked_unwrap/simple_conditionals.rs:183:12
    |
 LL |         if X.is_some() {
diff --git a/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.rs b/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.rs
index b09c96ada8ab6..5106ba6c86cd4 100644
--- a/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.rs
+++ b/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.rs
@@ -17,7 +17,7 @@ impl Foo {
 fn main() {
     unsafe {
         let sfoo: *mut Foo = &mut SFOO;
-        //~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
+        //~^ WARN mutable reference to mutable static [static_mut_refs]
         let x = (*sfoo).x();
         (*sfoo).x[1] += 1;
         *x += 1;
diff --git a/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr b/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr
index a392177ffe2f3..4e19fd81735e1 100644
--- a/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr
+++ b/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr
@@ -1,4 +1,4 @@
-warning: creating a mutable reference to mutable static is discouraged
+warning: creating a mutable reference to mutable static
   --> $DIR/borrowck-unsafe-static-mutable-borrows.rs:19:30
    |
 LL |         let sfoo: *mut Foo = &mut SFOO;
diff --git a/tests/ui/consts/const_let_assign2.rs b/tests/ui/consts/const_let_assign2.rs
index e8ebba7b20887..5349ae31bb4df 100644
--- a/tests/ui/consts/const_let_assign2.rs
+++ b/tests/ui/consts/const_let_assign2.rs
@@ -16,7 +16,7 @@ static mut BB: AA = AA::new();
 
 fn main() {
     let ptr = unsafe { &mut BB };
-    //~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
+    //~^ WARN mutable reference to mutable static [static_mut_refs]
     for a in ptr.data.iter() {
         println!("{}", a);
     }
diff --git a/tests/ui/consts/const_let_assign2.stderr b/tests/ui/consts/const_let_assign2.stderr
index 0d76f142d174d..1bb560437b60e 100644
--- a/tests/ui/consts/const_let_assign2.stderr
+++ b/tests/ui/consts/const_let_assign2.stderr
@@ -1,4 +1,4 @@
-warning: creating a mutable reference to mutable static is discouraged
+warning: creating a mutable reference to mutable static
   --> $DIR/const_let_assign2.rs:18:24
    |
 LL |     let ptr = unsafe { &mut BB };
diff --git a/tests/ui/issues/issue-39367.rs b/tests/ui/issues/issue-39367.rs
index 937d6c4b9e0b0..68b4d28aae3ba 100644
--- a/tests/ui/issues/issue-39367.rs
+++ b/tests/ui/issues/issue-39367.rs
@@ -20,7 +20,7 @@ fn arena() -> &'static ArenaSet<Vec<u8>> {
 
             static mut ONCE: Once = Once::new();
             ONCE.call_once(|| {
-            //~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
+            //~^ WARN creating a shared reference to mutable static [static_mut_refs]
                 DATA = transmute
                     ::<Box<ArenaSet<Vec<u8>>>, *const ArenaSet<Vec<u8>>>
                     (Box::new(__static_ref_initialize()));
diff --git a/tests/ui/issues/issue-39367.stderr b/tests/ui/issues/issue-39367.stderr
index 333c9f9634a31..df21c09983e26 100644
--- a/tests/ui/issues/issue-39367.stderr
+++ b/tests/ui/issues/issue-39367.stderr
@@ -1,4 +1,4 @@
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/issue-39367.rs:22:13
    |
 LL | /             ONCE.call_once(|| {
diff --git a/tests/ui/lint/static-mut-refs.e2021.stderr b/tests/ui/lint/static-mut-refs.e2021.stderr
index 00a2ca99f241c..320e0cee8e8b7 100644
--- a/tests/ui/lint/static-mut-refs.e2021.stderr
+++ b/tests/ui/lint/static-mut-refs.e2021.stderr
@@ -1,4 +1,4 @@
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:38:18
    |
 LL |         let _y = &X;
@@ -12,7 +12,7 @@ help: use `&raw const` instead to create a raw pointer
 LL |         let _y = &raw const X;
    |                   +++++++++
 
-warning: creating a mutable reference to mutable static is discouraged
+warning: creating a mutable reference to mutable static
   --> $DIR/static-mut-refs.rs:42:18
    |
 LL |         let _y = &mut X;
@@ -25,7 +25,7 @@ help: use `&raw mut` instead to create a raw pointer
 LL |         let _y = &raw mut X;
    |                   +++
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:50:22
    |
 LL |         let ref _a = X;
@@ -34,7 +34,7 @@ LL |         let ref _a = X;
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = 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
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:54:25
    |
 LL |         let (_b, _c) = (&X, &Y);
@@ -47,7 +47,7 @@ help: use `&raw const` instead to create a raw pointer
 LL |         let (_b, _c) = (&raw const X, &Y);
    |                          +++++++++
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:54:29
    |
 LL |         let (_b, _c) = (&X, &Y);
@@ -60,7 +60,7 @@ help: use `&raw const` instead to create a raw pointer
 LL |         let (_b, _c) = (&X, &raw const Y);
    |                              +++++++++
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:60:13
    |
 LL |         foo(&X);
@@ -73,7 +73,7 @@ help: use `&raw const` instead to create a raw pointer
 LL |         foo(&raw const X);
    |              +++++++++
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:66:17
    |
 LL |         let _ = Z.len();
@@ -82,7 +82,7 @@ LL |         let _ = Z.len();
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = 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
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:72:33
    |
 LL |         let _ = format!("{:?}", Z);
@@ -91,7 +91,7 @@ LL |         let _ = format!("{:?}", Z);
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = 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
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:76:18
    |
 LL |         let _v = &A.value;
@@ -104,7 +104,7 @@ help: use `&raw const` instead to create a raw pointer
 LL |         let _v = &raw const A.value;
    |                   +++++++++
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:80:18
    |
 LL |         let _s = &A.s.value;
@@ -117,7 +117,7 @@ help: use `&raw const` instead to create a raw pointer
 LL |         let _s = &raw const A.s.value;
    |                   +++++++++
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:84:22
    |
 LL |         let ref _v = A.value;
@@ -126,7 +126,7 @@ LL |         let ref _v = A.value;
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = 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
 
-warning: creating a mutable reference to mutable static is discouraged
+warning: creating a mutable reference to mutable static
   --> $DIR/static-mut-refs.rs:14:14
    |
 LL |         &mut ($x.0)
diff --git a/tests/ui/lint/static-mut-refs.e2024.stderr b/tests/ui/lint/static-mut-refs.e2024.stderr
index ff41f316250d1..bf7ffc62ce17b 100644
--- a/tests/ui/lint/static-mut-refs.e2024.stderr
+++ b/tests/ui/lint/static-mut-refs.e2024.stderr
@@ -1,4 +1,4 @@
-error: creating a shared reference to mutable static is discouraged
+error: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:38:18
    |
 LL |         let _y = &X;
@@ -12,7 +12,7 @@ help: use `&raw const` instead to create a raw pointer
 LL |         let _y = &raw const X;
    |                   +++++++++
 
-error: creating a mutable reference to mutable static is discouraged
+error: creating a mutable reference to mutable static
   --> $DIR/static-mut-refs.rs:42:18
    |
 LL |         let _y = &mut X;
@@ -25,7 +25,7 @@ help: use `&raw mut` instead to create a raw pointer
 LL |         let _y = &raw mut X;
    |                   +++
 
-error: creating a shared reference to mutable static is discouraged
+error: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:50:22
    |
 LL |         let ref _a = X;
@@ -34,7 +34,7 @@ LL |         let ref _a = X;
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = 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
 
-error: creating a shared reference to mutable static is discouraged
+error: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:54:25
    |
 LL |         let (_b, _c) = (&X, &Y);
@@ -47,7 +47,7 @@ help: use `&raw const` instead to create a raw pointer
 LL |         let (_b, _c) = (&raw const X, &Y);
    |                          +++++++++
 
-error: creating a shared reference to mutable static is discouraged
+error: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:54:29
    |
 LL |         let (_b, _c) = (&X, &Y);
@@ -60,7 +60,7 @@ help: use `&raw const` instead to create a raw pointer
 LL |         let (_b, _c) = (&X, &raw const Y);
    |                              +++++++++
 
-error: creating a shared reference to mutable static is discouraged
+error: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:60:13
    |
 LL |         foo(&X);
@@ -73,7 +73,7 @@ help: use `&raw const` instead to create a raw pointer
 LL |         foo(&raw const X);
    |              +++++++++
 
-error: creating a shared reference to mutable static is discouraged
+error: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:66:17
    |
 LL |         let _ = Z.len();
@@ -82,7 +82,7 @@ LL |         let _ = Z.len();
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = 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
 
-error: creating a shared reference to mutable static is discouraged
+error: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:72:33
    |
 LL |         let _ = format!("{:?}", Z);
@@ -91,7 +91,7 @@ LL |         let _ = format!("{:?}", Z);
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = 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
 
-error: creating a shared reference to mutable static is discouraged
+error: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:76:18
    |
 LL |         let _v = &A.value;
@@ -104,7 +104,7 @@ help: use `&raw const` instead to create a raw pointer
 LL |         let _v = &raw const A.value;
    |                   +++++++++
 
-error: creating a shared reference to mutable static is discouraged
+error: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:80:18
    |
 LL |         let _s = &A.s.value;
@@ -117,7 +117,7 @@ help: use `&raw const` instead to create a raw pointer
 LL |         let _s = &raw const A.s.value;
    |                   +++++++++
 
-error: creating a shared reference to mutable static is discouraged
+error: creating a shared reference to mutable static
   --> $DIR/static-mut-refs.rs:84:22
    |
 LL |         let ref _v = A.value;
@@ -126,7 +126,7 @@ LL |         let ref _v = A.value;
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = 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
 
-error: creating a mutable reference to mutable static is discouraged
+error: creating a mutable reference to mutable static
   --> $DIR/static-mut-refs.rs:14:14
    |
 LL |         &mut ($x.0)
diff --git a/tests/ui/lint/static-mut-refs.rs b/tests/ui/lint/static-mut-refs.rs
index 1040dfcae7a95..d2511fb5b128a 100644
--- a/tests/ui/lint/static-mut-refs.rs
+++ b/tests/ui/lint/static-mut-refs.rs
@@ -12,8 +12,8 @@ static mut FOO: (u32, u32) = (1, 2);
 macro_rules! bar {
     ($x:expr) => {
         &mut ($x.0)
-        //[e2021]~^ WARN creating a mutable reference to mutable static is discouraged [static_mut_refs]
-        //[e2024]~^^ ERROR creating a mutable reference to mutable static is discouraged [static_mut_refs]
+        //[e2021]~^ WARN creating a mutable reference to mutable static [static_mut_refs]
+        //[e2024]~^^ ERROR creating a mutable reference to mutable static [static_mut_refs]
     };
 }
 
@@ -36,54 +36,54 @@ fn main() {
 
     unsafe {
         let _y = &X;
-        //[e2021]~^ WARN shared reference to mutable static is discouraged [static_mut_refs]
-        //[e2024]~^^ ERROR shared reference to mutable static is discouraged [static_mut_refs]
+        //[e2021]~^ WARN shared reference to mutable static [static_mut_refs]
+        //[e2024]~^^ ERROR shared reference to mutable static [static_mut_refs]
 
         let _y = &mut X;
-        //[e2021]~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
-        //[e2024]~^^ ERROR mutable reference to mutable static is discouraged [static_mut_refs]
+        //[e2021]~^ WARN mutable reference to mutable static [static_mut_refs]
+        //[e2024]~^^ ERROR mutable reference to mutable static [static_mut_refs]
 
         let _z = &raw mut X;
 
         let _p = &raw const X;
 
         let ref _a = X;
-        //[e2021]~^ WARN shared reference to mutable static is discouraged [static_mut_refs]
-        //[e2024]~^^ ERROR shared reference to mutable static is discouraged [static_mut_refs]
+        //[e2021]~^ WARN shared reference to mutable static [static_mut_refs]
+        //[e2024]~^^ ERROR shared reference to mutable static [static_mut_refs]
 
         let (_b, _c) = (&X, &Y);
-        //[e2021]~^ WARN shared reference to mutable static is discouraged [static_mut_refs]
-        //[e2024]~^^ ERROR shared reference to mutable static is discouraged [static_mut_refs]
-        //[e2021]~^^^ WARN shared reference to mutable static is discouraged [static_mut_refs]
-        //[e2024]~^^^^ ERROR shared reference to mutable static is discouraged [static_mut_refs]
+        //[e2021]~^ WARN shared reference to mutable static [static_mut_refs]
+        //[e2024]~^^ ERROR shared reference to mutable static [static_mut_refs]
+        //[e2021]~^^^ WARN shared reference to mutable static [static_mut_refs]
+        //[e2024]~^^^^ ERROR shared reference to mutable static [static_mut_refs]
 
         foo(&X);
-        //[e2021]~^ WARN shared reference to mutable static is discouraged [static_mut_refs]
-        //[e2024]~^^ ERROR shared reference to mutable static is discouraged [static_mut_refs]
+        //[e2021]~^ WARN shared reference to mutable static [static_mut_refs]
+        //[e2024]~^^ ERROR shared reference to mutable static [static_mut_refs]
 
         static mut Z: &[i32; 3] = &[0, 1, 2];
 
         let _ = Z.len();
-        //[e2021]~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
-        //[e2024]~^^ ERROR creating a shared reference to mutable static is discouraged [static_mut_refs]
+        //[e2021]~^ WARN creating a shared reference to mutable static [static_mut_refs]
+        //[e2024]~^^ ERROR creating a shared reference to mutable static [static_mut_refs]
 
         let _ = Z[0];
 
         let _ = format!("{:?}", Z);
-        //[e2021]~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
-        //[e2024]~^^ ERROR creating a shared reference to mutable static is discouraged [static_mut_refs]
+        //[e2021]~^ WARN creating a shared reference to mutable static [static_mut_refs]
+        //[e2024]~^^ ERROR creating a shared reference to mutable static [static_mut_refs]
 
         let _v = &A.value;
-        //[e2021]~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
-        //[e2024]~^^ ERROR creating a shared reference to mutable static is discouraged [static_mut_refs]
+        //[e2021]~^ WARN creating a shared reference to mutable static [static_mut_refs]
+        //[e2024]~^^ ERROR creating a shared reference to mutable static [static_mut_refs]
 
         let _s = &A.s.value;
-        //[e2021]~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
-        //[e2024]~^^ ERROR creating a shared reference to mutable static is discouraged [static_mut_refs]
+        //[e2021]~^ WARN creating a shared reference to mutable static [static_mut_refs]
+        //[e2024]~^^ ERROR creating a shared reference to mutable static [static_mut_refs]
 
         let ref _v = A.value;
-        //[e2021]~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
-        //[e2024]~^^ ERROR creating a shared reference to mutable static is discouraged [static_mut_refs]
+        //[e2021]~^ WARN creating a shared reference to mutable static [static_mut_refs]
+        //[e2024]~^^ ERROR creating a shared reference to mutable static [static_mut_refs]
 
         let _x = bar!(FOO);
 
diff --git a/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs b/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs
index be882085c5c90..73597408d1061 100644
--- a/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs
+++ b/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs
@@ -15,7 +15,7 @@ struct S1 {
 impl S1 {
     fn new(_x: u64) -> S1 {
         S1 { a: unsafe { &mut X1 } }
-        //~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
+        //~^ WARN mutable reference to mutable static [static_mut_refs]
     }
 }
 
diff --git a/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr b/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr
index 9dbd676969364..8268f5df23655 100644
--- a/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr
+++ b/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr
@@ -1,4 +1,4 @@
-warning: creating a mutable reference to mutable static is discouraged
+warning: creating a mutable reference to mutable static
   --> $DIR/borrowck-thread-local-static-mut-borrow-outlives-fn.rs:17:26
    |
 LL |         S1 { a: unsafe { &mut X1 } }
diff --git a/tests/ui/statics/issue-15261.rs b/tests/ui/statics/issue-15261.rs
index ed79a201488f3..f8c5ebaa54840 100644
--- a/tests/ui/statics/issue-15261.rs
+++ b/tests/ui/statics/issue-15261.rs
@@ -2,10 +2,9 @@
 #![allow(dead_code)]
 #![allow(non_upper_case_globals)]
 
-
 static mut n_mut: usize = 0;
 
 static n: &'static usize = unsafe { &n_mut };
-//~^ WARN shared reference to mutable static is discouraged [static_mut_refs]
+//~^ WARN shared reference to mutable static [static_mut_refs]
 
 fn main() {}
diff --git a/tests/ui/statics/issue-15261.stderr b/tests/ui/statics/issue-15261.stderr
index 7e6aebcbb1f0e..d2dd762aa66eb 100644
--- a/tests/ui/statics/issue-15261.stderr
+++ b/tests/ui/statics/issue-15261.stderr
@@ -1,5 +1,5 @@
-warning: creating a shared reference to mutable static is discouraged
-  --> $DIR/issue-15261.rs:8:37
+warning: creating a shared reference to mutable static
+  --> $DIR/issue-15261.rs:7:37
    |
 LL | static n: &'static usize = unsafe { &n_mut };
    |                                     ^^^^^^ shared reference to mutable static
diff --git a/tests/ui/statics/static-mut-shared-parens.rs b/tests/ui/statics/static-mut-shared-parens.rs
index 8e58152e27acd..7eda7d67d9248 100644
--- a/tests/ui/statics/static-mut-shared-parens.rs
+++ b/tests/ui/statics/static-mut-shared-parens.rs
@@ -1,13 +1,12 @@
 //Missing paren in diagnostic msg: https://github.com/rust-lang/rust/issues/131977
 //@check-pass
 
-
 static mut TEST: usize = 0;
 
 fn main() {
     let _ = unsafe { (&TEST) as *const usize };
-    //~^WARN creating a shared reference to mutable static is discouraged
+    //~^WARN creating a shared reference to mutable static
 
-    let _ = unsafe { ((&mut TEST)) as *const usize };
-    //~^WARN creating a mutable reference to mutable static is discouraged
+    let _ = unsafe { (&mut TEST) as *const usize };
+    //~^WARN creating a mutable reference to mutable static
 }
diff --git a/tests/ui/statics/static-mut-shared-parens.stderr b/tests/ui/statics/static-mut-shared-parens.stderr
index 30a586c286ae7..3825e8efc4277 100644
--- a/tests/ui/statics/static-mut-shared-parens.stderr
+++ b/tests/ui/statics/static-mut-shared-parens.stderr
@@ -1,5 +1,5 @@
-warning: creating a shared reference to mutable static is discouraged
-  --> $DIR/static-mut-shared-parens.rs:8:22
+warning: creating a shared reference to mutable static
+  --> $DIR/static-mut-shared-parens.rs:7:22
    |
 LL |     let _ = unsafe { (&TEST) as *const usize };
    |                      ^^^^^^^ shared reference to mutable static
@@ -12,18 +12,18 @@ help: use `&raw const` instead to create a raw pointer
 LL |     let _ = unsafe { (&raw const TEST) as *const usize };
    |                        +++++++++
 
-warning: creating a mutable reference to mutable static is discouraged
-  --> $DIR/static-mut-shared-parens.rs:11:22
+warning: creating a mutable reference to mutable static
+  --> $DIR/static-mut-shared-parens.rs:10:22
    |
-LL |     let _ = unsafe { ((&mut TEST)) as *const usize };
-   |                      ^^^^^^^^^^^^^ mutable reference to mutable static
+LL |     let _ = unsafe { (&mut TEST) as *const usize };
+   |                      ^^^^^^^^^^^ mutable reference to mutable static
    |
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
 help: use `&raw mut` instead to create a raw pointer
    |
-LL |     let _ = unsafe { ((&raw mut TEST)) as *const usize };
-   |                         +++
+LL |     let _ = unsafe { (&raw mut TEST) as *const usize };
+   |                        +++
 
 warning: 2 warnings emitted
 
diff --git a/tests/ui/statics/static-mut-xc.rs b/tests/ui/statics/static-mut-xc.rs
index c23cc822ce741..878f5a8e0f70a 100644
--- a/tests/ui/statics/static-mut-xc.rs
+++ b/tests/ui/statics/static-mut-xc.rs
@@ -17,23 +17,23 @@ fn static_bound_set(a: &'static mut isize) {
 
 unsafe fn run() {
     assert_eq!(static_mut_xc::a, 3);
-    //~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
+    //~^ WARN creating a shared reference to mutable static [static_mut_refs]
     static_mut_xc::a = 4;
     assert_eq!(static_mut_xc::a, 4);
-    //~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
+    //~^ WARN creating a shared reference to mutable static [static_mut_refs]
     static_mut_xc::a += 1;
     assert_eq!(static_mut_xc::a, 5);
-    //~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
+    //~^ WARN creating a shared reference to mutable static [static_mut_refs]
     static_mut_xc::a *= 3;
     assert_eq!(static_mut_xc::a, 15);
-    //~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
+    //~^ WARN creating a shared reference to mutable static [static_mut_refs]
     static_mut_xc::a = -3;
     assert_eq!(static_mut_xc::a, -3);
-    //~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
+    //~^ WARN creating a shared reference to mutable static [static_mut_refs]
     static_bound(&static_mut_xc::a);
-    //~^ WARN shared reference to mutable static is discouraged [static_mut_refs]
+    //~^ WARN shared reference to mutable static [static_mut_refs]
     static_bound_set(&mut static_mut_xc::a);
-    //~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
+    //~^ WARN mutable reference to mutable static [static_mut_refs]
 }
 
 pub fn main() {
diff --git a/tests/ui/statics/static-mut-xc.stderr b/tests/ui/statics/static-mut-xc.stderr
index 69f334a5636af..2d7a0553e925f 100644
--- a/tests/ui/statics/static-mut-xc.stderr
+++ b/tests/ui/statics/static-mut-xc.stderr
@@ -1,4 +1,4 @@
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-xc.rs:19:16
    |
 LL |     assert_eq!(static_mut_xc::a, 3);
@@ -8,7 +8,7 @@ LL |     assert_eq!(static_mut_xc::a, 3);
    = 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
    = note: `#[warn(static_mut_refs)]` on by default
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-xc.rs:22:16
    |
 LL |     assert_eq!(static_mut_xc::a, 4);
@@ -17,7 +17,7 @@ LL |     assert_eq!(static_mut_xc::a, 4);
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = 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
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-xc.rs:25:16
    |
 LL |     assert_eq!(static_mut_xc::a, 5);
@@ -26,7 +26,7 @@ LL |     assert_eq!(static_mut_xc::a, 5);
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = 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
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-xc.rs:28:16
    |
 LL |     assert_eq!(static_mut_xc::a, 15);
@@ -35,7 +35,7 @@ LL |     assert_eq!(static_mut_xc::a, 15);
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = 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
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-xc.rs:31:16
    |
 LL |     assert_eq!(static_mut_xc::a, -3);
@@ -44,7 +44,7 @@ LL |     assert_eq!(static_mut_xc::a, -3);
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = 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
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-mut-xc.rs:33:18
    |
 LL |     static_bound(&static_mut_xc::a);
@@ -57,7 +57,7 @@ help: use `&raw const` instead to create a raw pointer
 LL |     static_bound(&raw const static_mut_xc::a);
    |                   +++++++++
 
-warning: creating a mutable reference to mutable static is discouraged
+warning: creating a mutable reference to mutable static
   --> $DIR/static-mut-xc.rs:35:22
    |
 LL |     static_bound_set(&mut static_mut_xc::a);
diff --git a/tests/ui/statics/static-recursive.rs b/tests/ui/statics/static-recursive.rs
index da23b54d1fca0..dab60dd8641bd 100644
--- a/tests/ui/statics/static-recursive.rs
+++ b/tests/ui/statics/static-recursive.rs
@@ -1,7 +1,7 @@
 //@ run-pass
 
 static mut S: *const u8 = unsafe { &S as *const *const u8 as *const u8 };
-//~^ WARN shared reference to mutable static is discouraged [static_mut_refs]
+//~^ WARN shared reference to mutable static [static_mut_refs]
 
 struct StaticDoubleLinked {
     prev: &'static StaticDoubleLinked,
@@ -17,7 +17,7 @@ static L3: StaticDoubleLinked = StaticDoubleLinked { prev: &L2, next: &L1, data:
 pub fn main() {
     unsafe {
         assert_eq!(S, *(S as *const *const u8));
-        //~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs]
+        //~^ WARN creating a shared reference to mutable static [static_mut_refs]
     }
 
     let mut test_vec = Vec::new();
diff --git a/tests/ui/statics/static-recursive.stderr b/tests/ui/statics/static-recursive.stderr
index 039934dfc692d..252807e2e5dea 100644
--- a/tests/ui/statics/static-recursive.stderr
+++ b/tests/ui/statics/static-recursive.stderr
@@ -1,4 +1,4 @@
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-recursive.rs:3:36
    |
 LL | static mut S: *const u8 = unsafe { &S as *const *const u8 as *const u8 };
@@ -12,7 +12,7 @@ help: use `&raw const` instead to create a raw pointer
 LL | static mut S: *const u8 = unsafe { &raw const S as *const *const u8 as *const u8 };
    |                                     +++++++++
 
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static
   --> $DIR/static-recursive.rs:19:20
    |
 LL |         assert_eq!(S, *(S as *const *const u8));


Reviews:
user: login: yuk1ty
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-20T01:47:38Z
user: login: jieyouxu
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-21T09:01:14Z
user: login: junderw
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-22T16:06:55Z
user: login: yuk1ty
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-23T13:24:09Z
user: login: jieyouxu
body: Thanks
state: APPROVED
author_association: MEMBER
submitted_at: 2025-04-28T09:01:39Z

Review comments:
diff_hunk: @@ -1,4 +1,4 @@
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static is not allowed
path: tests/ui/lint/static-mut-refs.e2021.stderr
user: login: yuk1ty
body: I would like to ask if we should keep the error message as "discouraged" here (or other tests related to 2021 Edition) since my update will change the existing message in 2021 Edition 🤔 This is the first time to contribute the diagnostic issue, it would be nice if someone could tell me about the compatibility thing.
created_at: 2025-04-20T01:47:38Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,4 +1,4 @@
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static is not allowed
path: tests/ui/lint/static-mut-refs.e2021.stderr
user: login: jieyouxu
body: The easy way is to reword this message to...

```
warning: creating a shared reference to mutable static
```

that way, it doesn't really matter if it's Edition 2021 / 2024.

The more complex way is to introduce different diagnostics between edition < 2024 and edition >= 2024, with edition 2021 wording being

```
warning: creating a shared reference to mutable static is discouraged
```

and edition 2024 wording being

```
error: creating a shared reference to mutable static is not allowed
```
created_at: 2025-04-21T09:01:14Z
author_association: MEMBER
diff_hunk: @@ -1,4 +1,4 @@
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static is not allowed
path: tests/ui/lint/static-mut-refs.e2021.stderr
user: login: junderw
body: I agree that `creating a shared reference to mutable static` is better.

The `warning: ` and `error: ` will be enough information to let people know whether it's discouraged or not allowed.

("error" implies not being allowed and "warning" implies being discouraged)
created_at: 2025-04-22T16:06:55Z
author_association: NONE
diff_hunk: @@ -1,4 +1,4 @@
-warning: creating a shared reference to mutable static is discouraged
+warning: creating a shared reference to mutable static is not allowed
path: tests/ui/lint/static-mut-refs.e2021.stderr
user: login: yuk1ty
body: @jieyouxu @junderw Thank you for the comment. I will follow "creating a shared reference to mutable static" because from my quick investigation, the implementation is going to be really complexed (I think it's possible but) if we employ switching messages between 2021 and 2024.
created_at: 2025-04-23T13:24:09Z
author_association: CONTRIBUTOR

PR comments:
user: login: rustbot
created_at: 2025-04-20T01:44:39Z
body: r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use `r?` to explicitly pick a reviewer
author_association: COLLABORATOR
user: login: rust-log-analyzer
created_at: 2025-04-20T02:20:58Z
body: 
The job **`x86_64-gnu-tools`** failed! Check out the build log: [(web)](https://github.com/rust-lang/rust/actions/runs/14554896504/job/40830541706) [(plain)](https://github.com/rust-lang/rust/commit/01eb09191994d795f5a81f1db2c849c8b42402a5/checks/40830541706/logs)

<details><summary><i>Click to see the possible cause of the failure (guessed by this bot)</i></summary>

```plain
tests/ui/ref_option/ref_option.all.fixed ... ok
tests/ui/non_std_lazy_static/non_std_lazy_static_fixable.fixed ... ok

FAILED TEST: tests/ui/checked_unwrap/simple_conditionals.rs
command: CLIPPY_CONF_DIR="tests" RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/clippy-driver" "--error-format=json" "--emit=metadata" "-Aunused" "-Ainternal_features" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Dwarnings" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps" "--extern=clippy_config=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_config-d66901fcf071c39e.rlib" "--extern=clippy_lints=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_lints-299b005361846292.rlib" "--extern=clippy_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_utils-c9d012fa1351c9a1.rlib" "--extern=futures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libfutures-6ae23cd7ef138de2.rlib" "--extern=if_chain=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libif_chain-d494e6b7c1a6e89b.rlib" "--extern=itertools=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libitertools-d4e4179d28fd4b4c.rlib" "--extern=parking_lot=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libparking_lot-c60316d1e8e896b7.rlib" "--extern=quote=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libquote-1717c86f14e427fe.rlib" "--extern=regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libregex-75c78277780d7d9c.rlib" "--extern=serde=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libserde-37f19c6bbbc5eedb.rlib" "--extern=serde_derive=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libserde_derive-b4ef3187156cf2a5.so" "--extern=syn=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libsyn-0086164b4f00891f.rlib" "--extern=tokio=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libtokio-ab47290081742c1b.rlib" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/release/deps" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/ui_test/0/tests/ui/checked_unwrap" "tests/ui/checked_unwrap/simple_conditionals.rs" "--edition" "2021"

error: actual output differed from expected
Execute `cargo uibless` to update `tests/ui/checked_unwrap/simple_conditionals.stderr` to the actual output
--- tests/ui/checked_unwrap/simple_conditionals.stderr
+++ <stderr output>
---
Full unnormalized output:
error: called `unwrap` on `x` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:47:9
   |
LL |     if x.is_some() {
   |     -------------- help: try: `if let Some(<item>) = x`
LL |         // unnecessary
LL |         x.unwrap();
   |         ^^^^^^^^^^
   |
note: the lint level is defined here
  --> tests/ui/checked_unwrap/simple_conditionals.rs:2:35
   |
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: called `expect` on `x` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:51:9
   |
LL |     if x.is_some() {
   |     -------------- help: try: `if let Some(<item>) = x`
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:55:9
   |
---
   |
LL |     if x.is_some() {
   |        ----------- because of this check
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:64:9
   |
---

error: called `unwrap` on `x` after checking its variant with `is_none`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:68:9
   |
LL |     if x.is_none() {
   |     -------------- help: try: `if let Some(<item>) = x`
...
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: called `unwrap` on `x` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:13:13
   |
LL |         if $a.is_some() {
   |         --------------- help: try: `if let Some(<item>) = x`
LL |             // unnecessary
LL |             $a.unwrap();
   |             ^^^^^^^^^^^
...
LL |     m!(x);
   |     ----- in this macro invocation
   |
   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

error: called `unwrap` on `x` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:81:9
   |
LL |     if x.is_ok() {
   |     ------------ help: try: `if let Ok(<item>) = x`
LL |         // unnecessary
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: called `expect` on `x` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:85:9
   |
LL |     if x.is_ok() {
   |     ------------ help: try: `if let Ok(<item>) = x`
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap_err()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:89:9
   |
LL |     if x.is_ok() {
   |        --------- because of this check
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:93:9
   |
LL |     if x.is_ok() {
   |        --------- because of this check
...
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: this call to `expect()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:97:9
   |
LL |     if x.is_ok() {
   |        --------- because of this check
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: called `unwrap_err` on `x` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:101:9
   |
LL |     if x.is_ok() {
   |     ------------ help: try: `if let Err(<item>) = x`
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:106:9
   |
LL |     if x.is_err() {
   |        ---------- because of this check
LL |         // will panic
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: called `unwrap_err` on `x` after checking its variant with `is_err`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:110:9
   |
LL |     if x.is_err() {
   |     ------------- help: try: `if let Err(<item>) = x`
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: called `unwrap` on `x` after checking its variant with `is_err`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:114:9
   |
LL |     if x.is_err() {
   |     ------------- help: try: `if let Ok(<item>) = x`
...
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: this call to `unwrap_err()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:118:9
   |
LL |     if x.is_err() {
   |        ---------- because of this check
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: called `unwrap` on `option` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:143:9
   |
LL |     if option.is_some() {
   |     ------------------- help: try: `if let Some(<item>) = &option`
LL |         option.as_ref().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:146:9
   |
---

error: called `unwrap` on `result` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:153:9
   |
LL |     if result.is_ok() {
   |     ----------------- help: try: `if let Ok(<item>) = &result`
LL |         result.as_ref().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:156:9
   |
LL |     if result.is_ok() {
   |        -------------- because of this check
...
LL |         result.as_ref().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: called `unwrap` on `option` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:162:9
   |
LL |     if option.is_some() {
   |     ------------------- help: try: `if let Some(<item>) = &mut option`
LL |         option.as_mut().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:165:9
   |
---

error: called `unwrap` on `result` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:171:9
   |
LL |     if result.is_ok() {
   |     ----------------- help: try: `if let Ok(<item>) = &mut result`
LL |         result.as_mut().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:174:9
   |
LL |     if result.is_ok() {
   |        -------------- because of this check
...
LL |         result.as_mut().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

---
full stderr:
error: called `unwrap` on `x` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:47:9
   |
LL |     if x.is_some() {
   |     -------------- help: try: `if let Some(<item>) = x`
LL |         // unnecessary
LL |         x.unwrap();
   |         ^^^^^^^^^^
   |
note: the lint level is defined here
  --> tests/ui/checked_unwrap/simple_conditionals.rs:2:35
   |
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: called `expect` on `x` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:51:9
   |
LL |     if x.is_some() {
   |     -------------- help: try: `if let Some(<item>) = x`
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:55:9
   |
---
   |
LL |     if x.is_some() {
   |        ----------- because of this check
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:64:9
   |
---

error: called `unwrap` on `x` after checking its variant with `is_none`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:68:9
   |
LL |     if x.is_none() {
   |     -------------- help: try: `if let Some(<item>) = x`
...
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: called `unwrap` on `x` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:13:13
   |
LL |         if $a.is_some() {
   |         --------------- help: try: `if let Some(<item>) = x`
LL |             // unnecessary
LL |             $a.unwrap();
   |             ^^^^^^^^^^^
...
LL |     m!(x);
   |     ----- in this macro invocation
   |
   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

error: called `unwrap` on `x` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:81:9
   |
LL |     if x.is_ok() {
   |     ------------ help: try: `if let Ok(<item>) = x`
LL |         // unnecessary
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: called `expect` on `x` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:85:9
   |
LL |     if x.is_ok() {
   |     ------------ help: try: `if let Ok(<item>) = x`
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap_err()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:89:9
   |
LL |     if x.is_ok() {
   |        --------- because of this check
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:93:9
   |
LL |     if x.is_ok() {
   |        --------- because of this check
...
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: this call to `expect()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:97:9
   |
LL |     if x.is_ok() {
   |        --------- because of this check
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: called `unwrap_err` on `x` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:101:9
   |
LL |     if x.is_ok() {
   |     ------------ help: try: `if let Err(<item>) = x`
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:106:9
   |
LL |     if x.is_err() {
   |        ---------- because of this check
LL |         // will panic
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: called `unwrap_err` on `x` after checking its variant with `is_err`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:110:9
   |
LL |     if x.is_err() {
   |     ------------- help: try: `if let Err(<item>) = x`
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: called `unwrap` on `x` after checking its variant with `is_err`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:114:9
   |
LL |     if x.is_err() {
   |     ------------- help: try: `if let Ok(<item>) = x`
...
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: this call to `unwrap_err()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:118:9
   |
LL |     if x.is_err() {
   |        ---------- because of this check
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: called `unwrap` on `option` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:143:9
   |
LL |     if option.is_some() {
   |     ------------------- help: try: `if let Some(<item>) = &option`
LL |         option.as_ref().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:146:9
   |
---

error: called `unwrap` on `result` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:153:9
   |
LL |     if result.is_ok() {
   |     ----------------- help: try: `if let Ok(<item>) = &result`
LL |         result.as_ref().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:156:9
   |
LL |     if result.is_ok() {
   |        -------------- because of this check
...
LL |         result.as_ref().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: called `unwrap` on `option` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:162:9
   |
LL |     if option.is_some() {
   |     ------------------- help: try: `if let Some(<item>) = &mut option`
LL |         option.as_mut().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:165:9
   |
---

error: called `unwrap` on `result` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:171:9
   |
LL |     if result.is_ok() {
   |     ----------------- help: try: `if let Ok(<item>) = &mut result`
LL |         result.as_mut().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:174:9
   |
LL |     if result.is_ok() {
   |        -------------- because of this check
...
LL |         result.as_mut().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

```

</details>

author_association: COLLABORATOR
user: login: rust-log-analyzer
created_at: 2025-04-25T04:46:30Z
body: 
The job **`x86_64-gnu-tools`** failed! Check out the build log: [(web)](https://github.com/rust-lang/rust/actions/runs/14656837194/job/41133327956) [(plain)](https://github.com/rust-lang/rust/commit/6daa8e9d42b5472818f0c9ed2b8a4aedef205a6c/checks/41133327956/logs)

<details><summary><i>Click to see the possible cause of the failure (guessed by this bot)</i></summary>

```plain
tests/ui/ref_option/ref_option.all.fixed ... ok
tests/ui/non_std_lazy_static/non_std_lazy_static_fixable.fixed ... ok

FAILED TEST: tests/ui/checked_unwrap/simple_conditionals.rs
command: CLIPPY_CONF_DIR="tests" RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/clippy-driver" "--error-format=json" "--emit=metadata" "-Aunused" "-Ainternal_features" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Dwarnings" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps" "--extern=clippy_config=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_config-af4b67ede62bd94a.rlib" "--extern=clippy_lints=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_lints-0e3b06cfaa0e629a.rlib" "--extern=clippy_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_utils-3f60d68f14f28ca6.rlib" "--extern=futures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libfutures-6ae23cd7ef138de2.rlib" "--extern=if_chain=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libif_chain-d494e6b7c1a6e89b.rlib" "--extern=itertools=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libitertools-d4e4179d28fd4b4c.rlib" "--extern=parking_lot=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libparking_lot-c60316d1e8e896b7.rlib" "--extern=quote=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libquote-1717c86f14e427fe.rlib" "--extern=regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libregex-75c78277780d7d9c.rlib" "--extern=serde=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libserde-37f19c6bbbc5eedb.rlib" "--extern=serde_derive=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libserde_derive-b4ef3187156cf2a5.so" "--extern=syn=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libsyn-0086164b4f00891f.rlib" "--extern=tokio=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/libtokio-ab47290081742c1b.rlib" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/release/deps" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/ui_test/0/tests/ui/checked_unwrap" "tests/ui/checked_unwrap/simple_conditionals.rs" "--edition" "2024"

error: actual output differed from expected
Execute `./x test src/tools/clippy --bless` to update `tests/ui/checked_unwrap/simple_conditionals.stderr` to the actual output
--- tests/ui/checked_unwrap/simple_conditionals.stderr
+++ <stderr output>
---
Full unnormalized output:
error: called `unwrap` on `x` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:47:9
   |
LL |     if x.is_some() {
   |     -------------- help: try: `if let Some(<item>) = x`
LL |         // unnecessary
LL |         x.unwrap();
   |         ^^^^^^^^^^
   |
note: the lint level is defined here
  --> tests/ui/checked_unwrap/simple_conditionals.rs:2:35
   |
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: called `expect` on `x` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:51:9
   |
LL |     if x.is_some() {
   |     -------------- help: try: `if let Some(<item>) = x`
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:55:9
   |
---
   |
LL |     if x.is_some() {
   |        ----------- because of this check
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:64:9
   |
---

error: called `unwrap` on `x` after checking its variant with `is_none`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:68:9
   |
LL |     if x.is_none() {
   |     -------------- help: try: `if let Some(<item>) = x`
...
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: called `unwrap` on `x` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:13:13
   |
LL |         if $a.is_some() {
   |         --------------- help: try: `if let Some(<item>) = x`
LL |             // unnecessary
LL |             $a.unwrap();
   |             ^^^^^^^^^^^
...
LL |     m!(x);
   |     ----- in this macro invocation
   |
   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

error: called `unwrap` on `x` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:81:9
   |
LL |     if x.is_ok() {
   |     ------------ help: try: `if let Ok(<item>) = x`
LL |         // unnecessary
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: called `expect` on `x` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:85:9
   |
LL |     if x.is_ok() {
   |     ------------ help: try: `if let Ok(<item>) = x`
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap_err()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:89:9
   |
LL |     if x.is_ok() {
   |        --------- because of this check
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:93:9
   |
LL |     if x.is_ok() {
   |        --------- because of this check
...
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: this call to `expect()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:97:9
   |
LL |     if x.is_ok() {
   |        --------- because of this check
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: called `unwrap_err` on `x` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:101:9
   |
LL |     if x.is_ok() {
   |     ------------ help: try: `if let Err(<item>) = x`
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:106:9
   |
LL |     if x.is_err() {
   |        ---------- because of this check
LL |         // will panic
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: called `unwrap_err` on `x` after checking its variant with `is_err`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:110:9
   |
LL |     if x.is_err() {
   |     ------------- help: try: `if let Err(<item>) = x`
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: called `unwrap` on `x` after checking its variant with `is_err`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:114:9
   |
LL |     if x.is_err() {
   |     ------------- help: try: `if let Ok(<item>) = x`
...
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: this call to `unwrap_err()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:118:9
   |
LL |     if x.is_err() {
   |        ---------- because of this check
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: called `unwrap` on `option` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:143:9
   |
LL |     if option.is_some() {
   |     ------------------- help: try: `if let Some(<item>) = &option`
LL |         option.as_ref().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:146:9
   |
---

error: called `unwrap` on `result` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:153:9
   |
LL |     if result.is_ok() {
   |     ----------------- help: try: `if let Ok(<item>) = &result`
LL |         result.as_ref().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:156:9
   |
LL |     if result.is_ok() {
   |        -------------- because of this check
...
LL |         result.as_ref().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: called `unwrap` on `option` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:162:9
   |
LL |     if option.is_some() {
   |     ------------------- help: try: `if let Some(<item>) = &mut option`
LL |         option.as_mut().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:165:9
   |
---

error: called `unwrap` on `result` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:171:9
   |
LL |     if result.is_ok() {
   |     ----------------- help: try: `if let Ok(<item>) = &mut result`
LL |         result.as_mut().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:174:9
   |
LL |     if result.is_ok() {
   |        -------------- because of this check
...
LL |         result.as_mut().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

---
full stderr:
error: called `unwrap` on `x` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:47:9
   |
LL |     if x.is_some() {
   |     -------------- help: try: `if let Some(<item>) = x`
LL |         // unnecessary
LL |         x.unwrap();
   |         ^^^^^^^^^^
   |
note: the lint level is defined here
  --> tests/ui/checked_unwrap/simple_conditionals.rs:2:35
   |
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: called `expect` on `x` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:51:9
   |
LL |     if x.is_some() {
   |     -------------- help: try: `if let Some(<item>) = x`
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:55:9
   |
---
   |
LL |     if x.is_some() {
   |        ----------- because of this check
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:64:9
   |
---

error: called `unwrap` on `x` after checking its variant with `is_none`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:68:9
   |
LL |     if x.is_none() {
   |     -------------- help: try: `if let Some(<item>) = x`
...
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: called `unwrap` on `x` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:13:13
   |
LL |         if $a.is_some() {
   |         --------------- help: try: `if let Some(<item>) = x`
LL |             // unnecessary
LL |             $a.unwrap();
   |             ^^^^^^^^^^^
...
LL |     m!(x);
   |     ----- in this macro invocation
   |
   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

error: called `unwrap` on `x` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:81:9
   |
LL |     if x.is_ok() {
   |     ------------ help: try: `if let Ok(<item>) = x`
LL |         // unnecessary
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: called `expect` on `x` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:85:9
   |
LL |     if x.is_ok() {
   |     ------------ help: try: `if let Ok(<item>) = x`
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap_err()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:89:9
   |
LL |     if x.is_ok() {
   |        --------- because of this check
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:93:9
   |
LL |     if x.is_ok() {
   |        --------- because of this check
...
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: this call to `expect()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:97:9
   |
LL |     if x.is_ok() {
   |        --------- because of this check
...
LL |         x.expect("an error message");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: called `unwrap_err` on `x` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:101:9
   |
LL |     if x.is_ok() {
   |     ------------ help: try: `if let Err(<item>) = x`
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:106:9
   |
LL |     if x.is_err() {
   |        ---------- because of this check
LL |         // will panic
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: called `unwrap_err` on `x` after checking its variant with `is_err`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:110:9
   |
LL |     if x.is_err() {
   |     ------------- help: try: `if let Err(<item>) = x`
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: called `unwrap` on `x` after checking its variant with `is_err`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:114:9
   |
LL |     if x.is_err() {
   |     ------------- help: try: `if let Ok(<item>) = x`
...
LL |         x.unwrap();
   |         ^^^^^^^^^^

error: this call to `unwrap_err()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:118:9
   |
LL |     if x.is_err() {
   |        ---------- because of this check
...
LL |         x.unwrap_err();
   |         ^^^^^^^^^^^^^^

error: called `unwrap` on `option` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:143:9
   |
LL |     if option.is_some() {
   |     ------------------- help: try: `if let Some(<item>) = &option`
LL |         option.as_ref().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:146:9
   |
---

error: called `unwrap` on `result` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:153:9
   |
LL |     if result.is_ok() {
   |     ----------------- help: try: `if let Ok(<item>) = &result`
LL |         result.as_ref().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:156:9
   |
LL |     if result.is_ok() {
   |        -------------- because of this check
...
LL |         result.as_ref().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: called `unwrap` on `option` after checking its variant with `is_some`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:162:9
   |
LL |     if option.is_some() {
   |     ------------------- help: try: `if let Some(<item>) = &mut option`
LL |         option.as_mut().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:165:9
   |
---

error: called `unwrap` on `result` after checking its variant with `is_ok`
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:171:9
   |
LL |     if result.is_ok() {
   |     ----------------- help: try: `if let Ok(<item>) = &mut result`
LL |         result.as_mut().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

error: this call to `unwrap()` will always panic
##[error]  --> tests/ui/checked_unwrap/simple_conditionals.rs:174:9
   |
LL |     if result.is_ok() {
   |        -------------- because of this check
...
LL |         result.as_mut().unwrap();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^

```

</details>

author_association: COLLABORATOR
user: login: rustbot
created_at: 2025-04-26T11:41:30Z
body: Some changes occurred in src/tools/clippy

cc @rust-lang/clippy
author_association: COLLABORATOR
user: login: jieyouxu
created_at: 2025-04-28T09:01:47Z
body: @bors r+ rollup
author_association: MEMBER
user: login: bors
created_at: 2025-04-28T09:01:51Z
body: :pushpin: Commit bffb7608ce727d61cb1d9d3bb58d5461375f59a5 has been approved by `jieyouxu`

It is now in the [queue](https://bors.rust-lang.org/homu/queue/rust) for this repository.

<!-- @bors r=jieyouxu bffb7608ce727d61cb1d9d3bb58d5461375f59a5 -->
<!-- homu: {"type":"Approved","sha":"bffb7608ce727d61cb1d9d3bb58d5461375f59a5","approver":"jieyouxu","queue":"https://bors.rust-lang.org/homu/queue/rust"} -->
author_association: COLLABORATOR