]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rust: allow `clippy::collapsible_if` globally
authorMiguel Ojeda <ojeda@kernel.org>
Sun, 26 Apr 2026 14:42:01 +0000 (16:42 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Thu, 30 Apr 2026 21:21:31 +0000 (23:21 +0200)
Similar to `clippy::collapsible_match` (globally allowed in the previous
commit), the `clippy::collapsible_if` lint [1] can make code harder to
read in certain cases.

Thus just let developers decide on their own.

In addition, remove the existing `expect` we had.

Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Suggested-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/rust-for-linux/DGROP5CHU1QZ.1OKJRAUZXE9WC@garyguo.net/
Link: https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260426144201.227108-2-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Makefile
drivers/android/binder/range_alloc/array.rs

index 621d84aa4700d8528b4c634620319cdeb8fda407..28f4ae4524413a71ac375fe2cd674677f9faf75a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -486,6 +486,7 @@ export rust_common_flags := --edition=2021 \
                            -Wclippy::as_ptr_cast_mut \
                            -Wclippy::as_underscore \
                            -Wclippy::cast_lossless \
+                           -Aclippy::collapsible_if \
                            -Aclippy::collapsible_match \
                            -Wclippy::ignored_unit_patterns \
                            -Aclippy::incompatible_msrv \
index ada1d1b4302e53d0d66dfcc7244aea234ada8a41..081d19b09d4bb480e95af5fcfeaa84cd10c1ac0b 100644 (file)
@@ -204,7 +204,6 @@ impl<T> ArrayRangeAllocator<T> {
         // caller will mark them as unused, which means that they can be freed if the system comes
         // under memory pressure.
         let mut freed_range = FreedRange::interior_pages(offset, size);
-        #[expect(clippy::collapsible_if)] // reads better like this
         if offset % PAGE_SIZE != 0 {
             if i == 0 || self.ranges[i - 1].endpoint() <= (offset & PAGE_MASK) {
                 freed_range.start_page_idx -= 1;