[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72ny+uSZ8wNyqozTUNma1tKfS4du0yd4+nTjioYmyw25CQ@mail.gmail.com>
Date: Thu, 22 May 2025 10:21:59 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Alexandre Courbot <acourbot@...dia.com>
Cc: Daniel Almeida <daniel.almeida@...labora.com>, Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>, Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>, Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, Fiona Behrens <me@...enk.dev>
Subject: Re: [PATCH v5] rust: kernel: add support for bits/genmask macros
On Thu, May 22, 2025 at 5:17 AM Alexandre Courbot <acourbot@...dia.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
Powered by blists - more mailing lists