Re: [PATCH v5] rust: kernel: add support for bits/genmask macros

Miguel Ojeda
2025-05-22T08:22:13Z

On Thu, May 22, 2025 at 5:17 AM Alexandre Courbot <acourbot@nvidia.com> wrote:
>
> // Compile-time error if `n` is out of bounds.
> pub const fn bit_u32(n: u32) -> u32 {
> // Only accept values known at compile-time.
> static_assert!(n < u32::BITS);
> 1u32 << n
> }

I think this was meant to be `build_assert!`. `static_assert!` cannot
be used when the value is potentially not known.

(It would need to be `#[inline]` too).

Cheers,
Miguel