lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250401221205.52381-1-ojeda@kernel.org>
Date: Wed,  2 Apr 2025 00:12:05 +0200
From: Miguel Ojeda <ojeda@...nel.org>
To: Miguel Ojeda <ojeda@...nel.org>,
	Alex Gaynor <alex.gaynor@...il.com>
Cc: Boqun Feng <boqun.feng@...il.com>,
	Gary Guo <gary@...yguo.net>,
	Björn Roy Baron <bjorn3_gh@...tonmail.com>,
	Benno Lossin <benno.lossin@...ton.me>,
	Andreas Hindborg <a.hindborg@...nel.org>,
	Alice Ryhl <aliceryhl@...gle.com>,
	Trevor Gross <tmgross@...ch.edu>,
	Danilo Krummrich <dakr@...nel.org>,
	rust-for-linux@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	patches@...ts.linux.dev
Subject: [PATCH] rust: clean Rust 1.86.0 new `clippy::needless_continue` cases

Starting with the upcoming Rust 1.86.0, Clippy's `needless_continue` lint
complains about the last statement of a loop [1], including cases like:

    while ... {
        match ... {
            ... if ... => {
                ...
                return ...;
            }
            _ => continue,
        }
    }

as well as nested `match`es in a loop.

Thus clean them up.

Link: https://github.com/rust-lang/rust-clippy/pull/13891 [1]
Signed-off-by: Miguel Ojeda <ojeda@...nel.org>
---
To be honest, I am not sure we want this.

The lint can find cases that should be simplified, and it has been a nice lint
so far, but somehow I feel that using `continue` shows the intent better when
it is alone in an arm like that, and I am not sure we want to force people to
try to find other ways to write the code either, in cases when that applies.

If others feel this reads worse, then I would be happy to disable the lint and
open an issue upstream to keep the cases that are more clear cut.

 rust/macros/helpers.rs | 2 +-
 rust/macros/kunit.rs   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/macros/helpers.rs b/rust/macros/helpers.rs
index a3ee27e29a6f..bfa3aa7441d2 100644
--- a/rust/macros/helpers.rs
+++ b/rust/macros/helpers.rs
@@ -81,7 +81,7 @@ pub(crate) fn function_name(input: TokenStream) -> Option<Ident> {
                 }
                 return None;
             }
-            _ => continue,
+            _ => (),
         }
     }
     None
diff --git a/rust/macros/kunit.rs b/rust/macros/kunit.rs
index 4f553ecf40c0..63f79e5ac290 100644
--- a/rust/macros/kunit.rs
+++ b/rust/macros/kunit.rs
@@ -54,7 +54,7 @@ pub(crate) fn kunit_tests(attr: TokenStream, ts: TokenStream) -> TokenStream {
                     };
                     tests.push(test_name);
                 }
-                _ => continue,
+                _ => (),
             },
             _ => (),
         }

base-commit: 08733088b566b58283f0f12fb73f5db6a9a9de30
--
2.49.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ