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(-)
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>
On Mon, Sep 21, 2026 at 12:49:28AM +0900, 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> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
On Mon, Sep 21, 2026 at 12:49:28AM +0900, 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> > --- Thanks for the cleanup Alexandre. Acked-by: Carlos Llamas <cmllamas@google.com>
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(-)
© 2016 - 2026 Red Hat, Inc.