From: Alice Ryhl <aliceryhl@google.com>
To: Miguel Ojeda <ojeda@kernel.org>
Cc: "Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Tamir Duberstein" <tamird@gmail.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@lists.linux.dev
Subject: Re: [PATCH] rust: disable `clippy::needless_continue`
Date: Mon, 14 Apr 2025 14:09:45 +0000 [thread overview]
Message-ID: <Z_0XKfAMnWElZDzU@google.com> (raw)
In-Reply-To: <20250403163805.67770-1-ojeda@kernel.org>
On Thu, Apr 03, 2025 at 06:38:05PM +0200, Miguel Ojeda wrote:
> Starting with 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.
>
> One solution is changing `continue` for `()` [2], but arguably using
> `continue` shows the intent better when it is alone in an arm like that.
>
> Moreover, 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.
>
> In addition, the help text does not really apply in the new cases the
> lint has introduced, e.g. here one cannot simply "drop" the expression:
>
> warning: this `continue` expression is redundant
> --> rust/macros/helpers.rs:85:18
> |
> 85 | _ => continue,
> | ^^^^^^^^
> |
> = help: consider dropping the `continue` expression
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_continue
> = note: requested on the command line with `-W clippy::needless-continue`
>
> The examples in the documentation do not show a case like this, either,
> so the second "help" line does not help.
>
> In addition, locally disabling the lint is not possible with `expect`,
> since the behavior differs across versions. Using `allow` would be
> possible, but, even then, an extra line just for this is a bit too much,
> especially if there are other ways to satisfy the lint.
>
> Finally, the lint is still in the "pedantic" category and disabled by
> default by Clippy.
>
> Thus disable the lint, at least for the time being.
>
> Feedback was submitted to upstream Clippy, in case this can be improved
> or perhaps the lint split into several [3].
>
> Link: https://github.com/rust-lang/rust-clippy/pull/13891 [1]
> Link: https://lore.kernel.org/rust-for-linux/20250401221205.52381-1-ojeda@kernel.org/ [2]
> Link: https://github.com/rust-lang/rust-clippy/issues/14536 [3]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
prev parent reply other threads:[~2025-04-14 14:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-03 16:38 [PATCH] rust: disable `clippy::needless_continue` Miguel Ojeda
2025-04-13 22:23 ` Miguel Ojeda
2025-04-14 14:09 ` Alice Ryhl [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z_0XKfAMnWElZDzU@google.com \
--to=aliceryhl@google.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=patches@lists.linux.dev \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@gmail.com \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox