]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rust_binder: clean `clippy::mem_replace_with_default` warning
authorMiguel Ojeda <ojeda@kernel.org>
Wed, 24 Sep 2025 13:05:10 +0000 (15:05 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Oct 2025 08:57:41 +0000 (10:57 +0200)
Clippy reports:

    error: replacing a value of type `T` with `T::default()` is better expressed using `core::mem::take`
       --> drivers/android/binder/node.rs:690:32
        |
    690 |             _unused_capacity = mem::replace(&mut inner.freeze_list, KVVec::new());
        |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `core::mem::take(&mut inner.freeze_list)`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default
        = note: `-D clippy::mem-replace-with-default` implied by `-D warnings`
        = help: to override `-D warnings` add `#[allow(clippy::mem_replace_with_default)]`

The suggestion seems fine, thus apply it.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/android/binder/node.rs

index ade895ef791ec5746f9f5c1bfc15f47d59829455..08d362deaf61e564c49c164a19defe0f73d7f373 100644 (file)
@@ -687,7 +687,7 @@ impl Node {
             );
         }
         if inner.freeze_list.is_empty() {
-            _unused_capacity = mem::replace(&mut inner.freeze_list, KVVec::new());
+            _unused_capacity = mem::take(&mut inner.freeze_list);
         }
     }