* [PATCH] binder: use irrefutable let patterns
@ 2026-09-20 15:49 Alexandre Courbot
2026-09-20 16:03 ` Gary Guo
0 siblings, 1 reply; 2+ messages in thread
From: Alexandre Courbot @ 2026-09-20 15:49 UTC (permalink / raw)
To: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
Christian Brauner, Carlos Llamas, Alice Ryhl
Cc: linux-kernel, rust-for-linux, Alexandre Courbot
Replace matches on infallible results with irrefutable let patterns,
which are available since Rust 1.82.
This removes boilerplate for handling impossible error variants.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
drivers/android/binder/freeze.rs | 6 ++----
drivers/android/binder/node/wrapper.rs | 6 ++----
drivers/android/binder/process.rs | 17 ++++-------------
3 files changed, 8 insertions(+), 21 deletions(-)
diff --git a/drivers/android/binder/freeze.rs b/drivers/android/binder/freeze.rs
index 66912b4cb527..d4fa017063dc 100644
--- a/drivers/android/binder/freeze.rs
+++ b/drivers/android/binder/freeze.rs
@@ -75,10 +75,8 @@ fn new(flags: kernel::alloc::Flags) -> Result<UninitFM, AllocError> {
}
fn init(ua: UninitFM, cookie: FreezeCookie, pid: i32) -> DLArc<FreezeMessage> {
- match ua.pin_init_with(DTRWrap::new(FreezeMessage { cookie, pid })) {
- Ok(msg) => ListArc::from(msg),
- Err(err) => match err {},
- }
+ let Ok(msg) = ua.pin_init_with(DTRWrap::new(FreezeMessage { cookie, pid }));
+ ListArc::from(msg)
}
}
diff --git a/drivers/android/binder/node/wrapper.rs b/drivers/android/binder/node/wrapper.rs
index 6e4ca01c941a..1240b558983d 100644
--- a/drivers/android/binder/node/wrapper.rs
+++ b/drivers/android/binder/node/wrapper.rs
@@ -20,10 +20,8 @@ pub(crate) fn new() -> Result<Self> {
}
pub(super) fn init(self, node: DArc<Node>) -> DLArc<dyn DeliverToRead> {
- match self.inner.pin_init_with(DTRWrap::new(NodeWrapper { node })) {
- Ok(initialized) => ListArc::from(initialized) as DLArc<dyn DeliverToRead>,
- Err(err) => match err {},
- }
+ let Ok(initialized) = self.inner.pin_init_with(DTRWrap::new(NodeWrapper { node }));
+ ListArc::from(initialized) as DLArc<dyn DeliverToRead>
}
}
diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs
index 5372bfbd93b3..67b07cbf9048 100644
--- a/drivers/android/binder/process.rs
+++ b/drivers/android/binder/process.rs
@@ -892,11 +892,8 @@ pub(crate) fn insert_or_update_handle(
let (info_proc, info_node) = {
let info_init = NodeRefInfo::new(node_ref, handle, self.into());
- match info.pin_init_with(info_init) {
- Ok(info) => ListArc::pair_from_pin_unique(info),
- // error is infallible
- Err(err) => match err {},
- }
+ let Ok(info) = info.pin_init_with(info_init);
+ ListArc::pair_from_pin_unique(info)
};
// Ensure the process is still alive while we insert a new reference.
@@ -1294,14 +1291,8 @@ pub(crate) fn request_death(
return Ok(());
}
- let death = {
- let death_init = NodeDeath::new(info.node_ref().node.clone(), self.clone(), cookie);
- match death.pin_init_with(death_init) {
- Ok(death) => death,
- // error is infallible
- Err(err) => match err {},
- }
- };
+ let death_init = NodeDeath::new(info.node_ref().node.clone(), self.clone(), cookie);
+ let Ok(death) = death.pin_init_with(death_init);
// Register the death notification.
{
---
base-commit: 40288c9206c17eb66a603262e06a58d300d0f279
change-id: 20260921-binder_let-d6c7446e0327
Best regards,
--
Alexandre Courbot <acourbot@nvidia.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] binder: use irrefutable let patterns
2026-09-20 15:49 [PATCH] binder: use irrefutable let patterns Alexandre Courbot
@ 2026-09-20 16:03 ` Gary Guo
0 siblings, 0 replies; 2+ messages in thread
From: Gary Guo @ 2026-09-20 16:03 UTC (permalink / raw)
To: Alexandre Courbot, Greg Kroah-Hartman, Arve Hjønnevåg,
Todd Kjos, Christian Brauner, Carlos Llamas, Alice Ryhl
Cc: linux-kernel, rust-for-linux
On Sun Sep 20, 2026 at 4:49 PM BST, Alexandre Courbot wrote:
> Replace matches on infallible results with irrefutable let patterns,
> which are available since Rust 1.82.
>
> This removes boilerplate for handling impossible error variants.
>
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
FWIW, this pattern can be served by `into_ok()` which is in the process of being
stabilized right now. This is also available in 1.85 unstably, however the
methods expect real never type (!) and does not work with `Infallible`.
Reviewed-by: Gary Guo <gary@garyguo.net>
> ---
> drivers/android/binder/freeze.rs | 6 ++----
> drivers/android/binder/node/wrapper.rs | 6 ++----
> drivers/android/binder/process.rs | 17 ++++-------------
> 3 files changed, 8 insertions(+), 21 deletions(-)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-20 16:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-20 15:49 [PATCH] binder: use irrefutable let patterns Alexandre Courbot
2026-09-20 16:03 ` Gary Guo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®