From 119b5984675cb43c2ecdf54195b418d3155eef94 Mon Sep 17 00:00:00 2001 From: Eliot Courtney Date: Mon, 10 Aug 2026 22:55:23 +0900 Subject: [PATCH] rust: num: use const_assert! in Bounded Convert the const-block asserts in bounded.rs to const_assert!, matching the rest of the file. Signed-off-by: Eliot Courtney Reviewed-by: Gary Guo Reviewed-by: Danilo Krummrich Suggested-by: Gary Guo Link: https://lore.kernel.org/rust-for-linux/DKIY9YGIPUUE.SZD2DUQM9NGK@garyguo.net/ Link: https://patch.msgid.link/20260810-pramin-split-v2-1-65a00b3c7309@nvidia.com Signed-off-by: Miguel Ojeda --- rust/kernel/num/bounded.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/kernel/num/bounded.rs b/rust/kernel/num/bounded.rs index dafe77782d79..9ad7df1a243d 100644 --- a/rust/kernel/num/bounded.rs +++ b/rust/kernel/num/bounded.rs @@ -485,7 +485,7 @@ pub fn cast(self) -> Bounded /// assert_eq!(v_shifted.get(), 0xff); /// ``` pub fn shr(self) -> Bounded { - const { assert!(RES + SHIFT >= N) } + const_assert!(RES + SHIFT >= N); // SAFETY: We shift the value right by `SHIFT`, reducing the number of bits needed to // represent the shifted value by as much, and just asserted that `RES >= N - SHIFT`. @@ -506,7 +506,7 @@ pub fn shr(self) -> Bounded { /// assert_eq!(v_shifted.get(), 0xff00); /// ``` pub fn shl(self) -> Bounded { - const { assert!(RES >= N + SHIFT) } + const_assert!(RES >= N + SHIFT); // SAFETY: We shift the value left by `SHIFT`, augmenting the number of bits needed to // represent the shifted value by as much, and just asserted that `RES >= N + SHIFT`.