Skip to content

Commit 2da76b8

Browse files
CastilloDelojeda
authored andcommitted
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 <gary@garyguo.net> Link: #1229 Signed-off-by: Daniel del Castillo <delcastillodelarosadaniel@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> 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 <ojeda@kernel.org>
1 parent 3cd202c commit 2da76b8

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

rust/kernel/error.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ pub mod code {
2525
#[doc = $doc]
2626
)*
2727
pub const $err: super::Error =
28-
match super::Error::try_from_errno(-(crate::bindings::$err as i32)) {
29-
Some(err) => err,
30-
None => panic!("Invalid errno in `declare_err!`"),
31-
};
28+
super::Error::try_from_errno(-(crate::bindings::$err as i32))
29+
.expect("Invalid errno in `declare_err!`");
3230
};
3331
}
3432

0 commit comments

Comments
 (0)