[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3f811c47-663c-4326-a7b5-cfe068e3b9d9@nvidia.com>
Date: Fri, 6 Feb 2026 15:37:45 -0800
From: John Hubbard <jhubbard@...dia.com>
To: Gary Guo <gary@...yguo.net>, Miguel Ojeda <ojeda@...nel.org>,
Boqun Feng <boqun@...nel.org>, 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>,
Alexandre Courbot <acourbot@...dia.com>, Yury Norov <yury.norov@...il.com>,
Nathan Chancellor <nathan@...nel.org>, Nicolas Schier <nsc@...nel.org>
Cc: linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
linux-kbuild@...r.kernel.org
Subject: Re: [PATCH 2/2] rust: add `const_assert!` macro
On 2/6/26 2:28 PM, Gary Guo wrote:
> On Fri Feb 6, 2026 at 10:21 PM GMT, John Hubbard wrote:
>> On 2/6/26 9:12 AM, Gary Guo wrote:
>>> From: Gary Guo <gary@...yguo.net>
...
>>> +/// Assertion during constant evaluation.
>>> +///
>>> +/// This is a more powerful version of `static_assert` that can refer to generics inside functions
>>> +/// or implementation blocks. However, it also have a limitation where it can only appear in places
>>> +/// where statements can appear; for example, you cannot use it as an item in the module.
>>> +///
>>> +/// [`static_assert!`] should be preferred where possible.
>>
>> Over what? There are 3 different assertion types. If it is actually
>> possible to list a clear order of preference, then let's list all
>> 3 in order, rather than having a scattering around of "A is
>> better than B", "C is sometimes worse than A", and then the
>> reader has to play treasure hunt to work it out. haha :)
>
> I am trying to avoid listing all assertion macros in all assertions macros,
> that's just going to be duplications.
>
> How about remove `#[doc(hidden)]` on `mod build_assert` and enumerate all
> assertions in the module documentation and give them rankings there?
>
Maybe yes? In any case, let's at least clarify the preference one-liner
above. Something like:
/// [`static_assert!`] should be preferred over [`const_assert!`]
/// because ...
(If that's even correct. I'm a little vague on the intent still.)
thanks,
--
John Hubbard
Powered by blists - more mailing lists