Skip to content

Commit af5d453

Browse files
ojedajfvogel
authored andcommitted
rust: disable clippy::needless_continue
commit 0866ee8e50f017731b80891294c0edd0f5fcd0a9 upstream. 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]. Cc: [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs). Link: rust-lang/rust-clippy#13891 [1] Link: https://lore.kernel.org/rust-for-linux/[email protected]/ [2] Link: rust-lang/rust-clippy#14536 [3] Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Alice Ryhl <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit baf02dd01e75314a6b1e60a53f30fdb64397d636) Signed-off-by: Jack Vogel <[email protected]>
1 parent 14a9878 commit af5d453

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ export rust_common_flags := --edition=2021 \
457457
-Wclippy::ignored_unit_patterns \
458458
-Wclippy::mut_mut \
459459
-Wclippy::needless_bitwise_bool \
460-
-Wclippy::needless_continue \
461460
-Aclippy::needless_lifetimes \
462461
-Wclippy::no_mangle_with_rust_abi \
463462
-Wclippy::undocumented_unsafe_blocks \

0 commit comments

Comments
 (0)