* [PATCH] rust_binder: clean Clippy `mem-replace-with-default` warning
@ 2025-10-12 21:32 Miguel Ojeda
2025-10-13 9:19 ` Alice Ryhl
2025-10-19 19:42 ` Miguel Ojeda
0 siblings, 2 replies; 3+ messages in thread
From: Miguel Ojeda @ 2025-10-12 21:32 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Greg Kroah-Hartman,
Arve Hjønnevåg, Todd Kjos, Martijn Coenen,
Joel Fernandes, Christian Brauner, Carlos Llamas,
Suren Baghdasaryan
Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
rust-for-linux, linux-kernel, patches
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.
Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
drivers/android/binder/node.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/android/binder/node.rs b/drivers/android/binder/node.rs
index ade895ef791e..08d362deaf61 100644
--- a/drivers/android/binder/node.rs
+++ b/drivers/android/binder/node.rs
@@ -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
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] rust_binder: clean Clippy `mem-replace-with-default` warning
2025-10-12 21:32 [PATCH] rust_binder: clean Clippy `mem-replace-with-default` warning Miguel Ojeda
@ 2025-10-13 9:19 ` Alice Ryhl
2025-10-19 19:42 ` Miguel Ojeda
1 sibling, 0 replies; 3+ messages in thread
From: Alice Ryhl @ 2025-10-13 9:19 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Alex Gaynor, Greg Kroah-Hartman, Arve Hjønnevåg,
Todd Kjos, Martijn Coenen, Joel Fernandes, Christian Brauner,
Carlos Llamas, Suren Baghdasaryan, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
patches
On Sun, Oct 12, 2025 at 11:32:30PM +0200, Miguel Ojeda wrote:
> 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.
>
> Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Thanks. I guess I never got around to making use of commit 47d8101924b5
("rust: vec: impl Default for Vec with any allocator").
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rust_binder: clean Clippy `mem-replace-with-default` warning
2025-10-12 21:32 [PATCH] rust_binder: clean Clippy `mem-replace-with-default` warning Miguel Ojeda
2025-10-13 9:19 ` Alice Ryhl
@ 2025-10-19 19:42 ` Miguel Ojeda
1 sibling, 0 replies; 3+ messages in thread
From: Miguel Ojeda @ 2025-10-19 19:42 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Alex Gaynor, Greg Kroah-Hartman, Arve Hjønnevåg,
Todd Kjos, Martijn Coenen, Joel Fernandes, Christian Brauner,
Carlos Llamas, Suren Baghdasaryan, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
patches
On Sun, Oct 12, 2025 at 11:32 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> 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.
>
> Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
For completeness: this is a duplicate (from myself!) of
https://lore.kernel.org/all/20250924130510.752115-1-ojeda@kernel.org/
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-19 19:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-12 21:32 [PATCH] rust_binder: clean Clippy `mem-replace-with-default` warning Miguel Ojeda
2025-10-13 9:19 ` Alice Ryhl
2025-10-19 19:42 ` Miguel Ojeda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).