rust_binder: clean Clippy `mem-replace-with-default` warning
Subsystems (2)
Miguel Ojeda
maintainerPATCH 1/1 rust_binder: clean Clippy `mem-replace-with-default` warning
Starting with Rust 1.87.0, Clippy reports:
CLIPPY drivers/android/binder/rust_binder_main.o
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)]`Thus clean it up as suggested.
--- drivers/android/binder/node.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/android/binder/node.rs +1 -1
@@ -687,7 +687,7 @@ pub(crate) fn remove_freeze_listener(&self, p: &Arc<Process>) { ); }if inner.freeze_list.is_empty () { - _unused_capacity = mem::replace (&mut inner.freeze_list,KVVec ::new ()); + _unused_capacity = mem::take (&mut inner.freeze_list); } }
base-commit: 8765f467912ff0d4832eeaf26ae573792da877e7
Signature · 1 line
2.51.0
Quoted 13 lines · Miguel Ojeda
Starting with Rust 1.87.0, Clippy reports:
CLIPPY drivers/android/binder/rust_binder_main.o 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)]`
Quoted 4 lines
Thus clean it up as suggested.
Fixes eafedbc7c050 ("rust_binder: add Rust Binder driver")Signed-off-by Miguel Ojeda <[email protected]>
Thanks. I guess I never got around to making use of commit 47d8101924b5 ("rust: vec: impl Default for Vec with any allocator").
Quoted 14 lines · Miguel Ojeda
Starting with Rust 1.87.0, Clippy reports:
CLIPPY drivers/android/binder/rust_binder_main.o 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)]`
Quoted 4 lines
Thus clean it up as suggested.
Fixes eafedbc7c050 ("rust_binder: add Rust Binder driver")Signed-off-by Miguel Ojeda <[email protected]>
For completeness: this is a duplicate (from myself!) of
https://lore.kernel.org/all/[email protected]/
which Greg already applied as commit 7e69a24b6b35 ("rust_binder: clean clippy::mem_replace_with_default warning"), in -next for a few days.
It would be nice to get it to Linus soon, so that Clippy builds are clean.
Thanks!
Cheers,
Miguel