]> www.infradead.org Git - users/hch/xfs.git/commitdiff
rust: allow `clippy::needless_lifetimes`
authorMiguel Ojeda <ojeda@kernel.org>
Sat, 16 Nov 2024 18:15:37 +0000 (19:15 +0100)
committerMiguel Ojeda <ojeda@kernel.org>
Sun, 24 Nov 2024 23:09:16 +0000 (00:09 +0100)
In beta Clippy (i.e. Rust 1.83.0), the `needless_lifetimes` lint has
been extended [1] to suggest eliding `impl` lifetimes, e.g.

    error: the following explicit lifetimes could be elided: 'a
    --> rust/kernel/list.rs:647:6
        |
    647 | impl<'a, T: ?Sized + ListItem<ID>, const ID: u64> FusedIterator for Iter<'a, T, ID> {}
        |      ^^                                                                  ^^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
        = note: `-D clippy::needless-lifetimes` implied by `-D warnings`
        = help: to override `-D warnings` add `#[allow(clippy::needless_lifetimes)]`
    help: elide the lifetimes
        |
    647 - impl<'a, T: ?Sized + ListItem<ID>, const ID: u64> FusedIterator for Iter<'a, T, ID> {}
    647 + impl<T: ?Sized + ListItem<ID>, const ID: u64> FusedIterator for Iter<'_, T, ID> {}

A possibility would have been to clean them -- the RFC patch [2] did
this, while asking if we wanted these cleanups. There is an open issue
[3] in Clippy about being able to differentiate some of the new cases,
e.g. those that do not involve introducing `'_`. Thus it seems others
feel similarly.

Thus, for the time being, we decided to `allow` the lint.

Link: https://github.com/rust-lang/rust-clippy/pull/13286
Link: https://lore.kernel.org/rust-for-linux/20241012231300.397010-1-ojeda@kernel.org/
Link: https://github.com/rust-lang/rust-clippy/issues/13514
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Link: https://lore.kernel.org/r/20241116181538.369355-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Makefile

index a9e723cb05961877d5e6b50920dcabc78cf4988f..00a444603fb14c7c1051063ad832ce982947015d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -456,6 +456,7 @@ export rust_common_flags := --edition=2021 \
                            -Wclippy::mut_mut \
                            -Wclippy::needless_bitwise_bool \
                            -Wclippy::needless_continue \
+                           -Aclippy::needless_lifetimes \
                            -Wclippy::no_mangle_with_rust_abi \
                            -Wclippy::undocumented_unsafe_blocks \
                            -Wclippy::unnecessary_safety_comment \