Skip to content

Commit cbad579

Browse files
ojedasmb49
authored andcommitted
rust: enable clippy::ignored_unit_patterns lint
BugLink: https://bugs.launchpad.net/bugs/2107437 commit 3fcc233 upstream. In Rust 1.73.0, Clippy introduced the `ignored_unit_patterns` lint [1]: > Matching with `()` explicitly instead of `_` outlines the fact that > the pattern contains no data. Also it would detect a type change > that `_` would ignore. There is only a single case that requires a change: error: matching over `()` is more explicit --> rust/kernel/types.rs:176:45 | 176 | ScopeGuard::new_with_data((), move |_| cleanup()) | ^ help: use `()` instead of `_`: `()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ignored_unit_patterns = note: requested on the command line with `-D clippy::ignored-unit-patterns` Thus clean it up and enable the lint -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#/ignored_unit_patterns [1] Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Trevor Gross <tmgross@umich.edu> Tested-by: Gary Guo <gary@garyguo.net> Reviewed-by: Gary Guo <gary@garyguo.net> Link: https://lore.kernel.org/r/20240904204347.168520-8-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Noah Wager <noah.wager@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 5aaaa37 commit cbad579

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ export rust_common_flags := --edition=2021 \
453453
-Wunreachable_pub \
454454
-Wclippy::all \
455455
-Wclippy::dbg_macro \
456+
-Wclippy::ignored_unit_patterns \
456457
-Wclippy::mut_mut \
457458
-Wclippy::needless_bitwise_bool \
458459
-Wclippy::needless_continue \

rust/kernel/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl<T, F: FnOnce(T)> ScopeGuard<T, F> {
195195
impl ScopeGuard<(), fn(())> {
196196
/// Creates a new guarded object with the given cleanup function.
197197
pub fn new(cleanup: impl FnOnce()) -> ScopeGuard<(), impl FnOnce(())> {
198-
ScopeGuard::new_with_data((), move |_| cleanup())
198+
ScopeGuard::new_with_data((), move |()| cleanup())
199199
}
200200
}
201201

0 commit comments

Comments
 (0)