[PATCH] rust: pin-init: use irrefutable pattern for `stack_pin_init`

From: Gary Guo

Date: Fri Aug 28 2026 - 11:51:41 EST


From: Gary Guo <gary@xxxxxxxxxxx>

In Rust 1.100.0, `Infallible` will become an alias of `!`. The let
binding in `stack_pin_init` will thus become unreachable and produce a
"unreachable expression" warning for subsequent match, and thus will fail
`-Dwarnings` build. For this macro, all we need to know is that the error
type is uninhabited, so replace this with a irrefutable pattern instead.

Reported-by: Mohamad Alsadhan <mo@xxxxxxx>
Closes: https://github.com/Rust-for-Linux/pin-init/pull/171
Signed-off-by: Gary Guo <gary@xxxxxxxxxxx>
---
Miguel, given that we're very early in the cycle and this effect
upcoming nightly compiler, I'd prefer to route this via rust-fixes
instead of pin-init-next. Thanks.
---
rust/pin-init/src/lib.rs | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/rust/pin-init/src/lib.rs b/rust/pin-init/src/lib.rs
index 7600cdbbbf98..f1463be9479d 100644
--- a/rust/pin-init/src/lib.rs
+++ b/rust/pin-init/src/lib.rs
@@ -490,13 +490,7 @@ macro_rules! stack_pin_init {
(let $var:ident $(: $t:ty)? = $val:expr) => {
let val = $val;
let mut $var = ::core::pin::pin!($crate::__internal::StackInit$(::<$t>)?::uninit());
- let mut $var = match $crate::__internal::StackInit::init($var, val) {
- Ok(res) => res,
- Err(x) => {
- let x: ::core::convert::Infallible = x;
- match x {}
- }
- };
+ let Ok(mut $var) = $crate::__internal::StackInit::init($var, val);
};
}


base-commit: d8aa025c1cd5908eb454e48af031370f23d3c559
--
2.54.0