From: Daniel del Castillo Date: Wed, 8 Apr 2026 20:09:39 +0000 (+0200) Subject: rust: error: replace match + panic in const context with const expect X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=2da76b814ec068e88d2260da5fa8575012227a5a;p=thirdparty%2Fkernel%2Flinux.git rust: error: replace match + panic in const context with const expect This patch replaces an instance of match + panic with const expect, which is now usable in const contexts after the MSRV was updated to 1.85.0 (it was available since Rust 1.83.0). Suggested-by: Gary Guo Link: https://github.com/Rust-for-Linux/linux/issues/1229 Signed-off-by: Daniel del Castillo Reviewed-by: Alice Ryhl Link: https://patch.msgid.link/20260408200949.99059-1-delcastillodelarosadaniel@gmail.com [ Adjusted Git author's name with the Signed-off-by value. Reworded slightly and removed duplicated word. - Miguel ] Signed-off-by: Miguel Ojeda --- diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs index 05cf869ac0908..a56ba63095944 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -25,10 +25,8 @@ pub mod code { #[doc = $doc] )* pub const $err: super::Error = - match super::Error::try_from_errno(-(crate::bindings::$err as i32)) { - Some(err) => err, - None => panic!("Invalid errno in `declare_err!`"), - }; + super::Error::try_from_errno(-(crate::bindings::$err as i32)) + .expect("Invalid errno in `declare_err!`"); }; }