[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72kUsG10+E-W6zhFXhexZV+O_a-K1Px0kGkWPKvMMhAztQ@mail.gmail.com>
Date: Mon, 8 Sep 2025 16:21:26 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Alexandre Courbot <acourbot@...dia.com>
Cc: 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 <lossin@...nel.org>, 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, nouveau@...ts.freedesktop.org
Subject: Re: [PATCH v5 1/2] rust: add `Alignment` type
On Mon, Sep 8, 2025 at 3:26 PM Alexandre Courbot <acourbot@...dia.com> wrote:
>
> + if ALIGN.is_power_of_two() {
> + // INVARIANT: `align` is a power of two.
> + // SAFETY: `align` is a power of two, and thus non-zero.
> + Self(unsafe { NonZero::new_unchecked(ALIGN) })
> + } else {
> + build_error!("Provided alignment is not a power of two.");
> + }
Would `build_assert!` at the top work instead?
> + /// Returns this alignment as a `usize`.
Intra-doc link.
> + // SAFETY: per the invariants, `self.0` is always a power of two so this block will
"Per".
I can pick this, with or without the user -- or do you need this in
Nova this cycle?
Thanks!
Cheers,
Miguel
Powered by blists - more mailing lists