[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <D8VPGBN60E61.1Z48FQW6TL3A@proton.me>
Date: Tue, 01 Apr 2025 23:53:05 +0000
From: Benno Lossin <benno.lossin@...ton.me>
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>, 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: Re: [PATCH] rust: clean Rust 1.86.0 new `clippy::needless_continue` cases
On Wed Apr 2, 2025 at 12:12 AM CEST, Miguel Ojeda wrote:
> 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.
I'm not too sure about this change, if the loop is longer than one
screen, it makes a lot of sense to have a `continue` instead of `()`,
since one might not see that there is nothing after the `match`.
I also think that an explicit `continue` is nicer from a expressability
standpoint. So I think we should keep them.
---
Cheers,
Benno
> rust/macros/helpers.rs | 2 +-
> rust/macros/kunit.rs | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
Powered by blists - more mailing lists