* [PATCH] rust: disable `clippy::needless_continue`
@ 2025-04-03 16:38 Miguel Ojeda
2025-04-13 22:23 ` Miguel Ojeda
2025-04-14 14:09 ` Alice Ryhl
0 siblings, 2 replies; 3+ messages in thread
From: Miguel Ojeda @ 2025-04-03 16:38 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor
Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
Tamir Duberstein, rust-for-linux, linux-kernel, patches
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>
---
Makefile | 1 -
1 file changed, 1 deletion(-)
diff --git a/Makefile b/Makefile
index d138b17b8840..2c33d25c505c 100644
--- a/Makefile
+++ b/Makefile
@@ -480,7 +480,6 @@ export rust_common_flags := --edition=2021 \
-Wclippy::ignored_unit_patterns \
-Wclippy::mut_mut \
-Wclippy::needless_bitwise_bool \
- -Wclippy::needless_continue \
-Aclippy::needless_lifetimes \
-Wclippy::no_mangle_with_rust_abi \
-Wclippy::undocumented_unsafe_blocks \
base-commit: a2cc6ff5ec8f91bc463fd3b0c26b61166a07eb11
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] rust: disable `clippy::needless_continue`
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
1 sibling, 0 replies; 3+ messages in thread
From: Miguel Ojeda @ 2025-04-13 22:23 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Tamir Duberstein, rust-for-linux, linux-kernel,
patches
On Thu, Apr 3, 2025 at 6:38 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Thus disable the lint, at least for the time being.
Applied to `rust-fixes` -- thanks for the feedback in the other thread
everyone! Tags still welcome for a day or two.
Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is
pinned in older LTSs).
Note that we don't have any cases before 6.15, but I added Cc: stable
since I assume we may in the future, and it is easier to just have the
same set everywhere.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rust: disable `clippy::needless_continue`
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
1 sibling, 0 replies; 3+ messages in thread
From: Alice Ryhl @ 2025-04-14 14:09 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich,
Tamir Duberstein, rust-for-linux, linux-kernel, patches
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-14 14:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox