All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alice Ryhl <aliceryhl@google.com>
To: Gary Guo <gary@garyguo.net>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Yury Norov" <yury.norov@gmail.com>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nicolas Schier" <nsc@kernel.org>,
	"Yury Norov" <ynorov@nvidia.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kbuild@vger.kernel.org
Subject: Re: [PATCH v3 2/4] rust: add `const_assert!` macro
Date: Thu, 19 Mar 2026 14:34:38 +0000	[thread overview]
Message-ID: <abwJfsEHd10hqAOb@google.com> (raw)
In-Reply-To: <DH6TTZXH3JKU.1URETSC28K6TZ@garyguo.net>

On Thu, Mar 19, 2026 at 02:26:06PM +0000, Gary Guo wrote:
> On Thu Mar 19, 2026 at 2:12 PM GMT, Alice Ryhl wrote:
> > On Thu, Mar 19, 2026 at 12:16:46PM +0000, Gary Guo wrote:
> >> From: Gary Guo <gary@garyguo.net>
> >> 
> >> The macro is a more powerful version of `static_assert!` for use inside
> >> function contexts. This is powered by inline consts, so enable the feature
> >> for old compiler versions that does not have it stably.
> >> 
> >> While it is possible already to write `const { assert!(...) }`, this
> >> provides a short hand that is more uniform with other assertions. It also
> >> formats nicer with rustfmt where it will not be formatted into multiple
> >> lines.
> >> 
> >> Two users that would route via the Rust tree are converted.
> >> 
> >> Reviewed-by: Yury Norov <ynorov@nvidia.com>
> >> Signed-off-by: Gary Guo <gary@garyguo.net>
> >
> > Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> >
> > It may be worth to mention in docs that const_assert! may only be
> > checked if the function it appears in has a caller. Whereas
> > static_assert! is always checked no matter what.
> >
> > Alice
> 
> I explained this in patch 3 on why `static_assert!` is preferred over
> `const_assert!`. Given that we recommend `const_assert!` only when it refers to
> generics, the check is inherently tied to a specific instance anyway, so I don't
> think it needs to be mentioned in the item doc.

Ok.

  reply	other threads:[~2026-03-19 14:34 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19 12:16 [PATCH v3 0/4] add `const_assert!` macro and rework documentation Gary Guo
2026-03-19 12:16 ` [PATCH v3 1/4] rust: move `static_assert` into `build_assert` Gary Guo
2026-03-19 14:09   ` Alice Ryhl
2026-03-19 12:16 ` [PATCH v3 2/4] rust: add `const_assert!` macro Gary Guo
2026-03-19 14:12   ` Alice Ryhl
2026-03-19 14:26     ` Gary Guo
2026-03-19 14:34       ` Alice Ryhl [this message]
2026-03-21 13:05   ` Alexandre Courbot
2026-03-19 12:16 ` [PATCH v3 3/4] rust: rework `build_assert!` documentation Gary Guo
2026-03-19 14:17   ` Alice Ryhl
2026-03-21 13:05   ` Alexandre Courbot
2026-03-19 12:16 ` [PATCH v3 4/4] rust: make `build_assert` module the home of related macros Gary Guo
2026-03-19 14:14   ` Danilo Krummrich
2026-03-19 14:14     ` Danilo Krummrich
2026-03-19 14:33   ` Alice Ryhl
2026-03-19 14:33     ` Alice Ryhl
2026-03-21 13:05   ` Alexandre Courbot
2026-03-21 13:05     ` Alexandre Courbot
2026-03-21 13:32     ` Gary Guo
2026-03-21 13:32       ` Gary Guo
2026-03-21 13:41       ` Miguel Ojeda
2026-03-21 13:41         ` Miguel Ojeda
2026-03-22 23:36   ` Miguel Ojeda
2026-03-22 23:36     ` Miguel Ojeda
2026-03-23  1:08     ` Alexandre Courbot
2026-03-23  1:08       ` Alexandre Courbot
2026-03-23  1:38       ` Miguel Ojeda
2026-03-23  1:38         ` Miguel Ojeda
2026-03-23  1:50         ` Alexandre Courbot
2026-03-26 12:09     ` FUJITA Tomonori
2026-03-26 12:09       ` FUJITA Tomonori
2026-03-27 18:42     ` Boqun Feng
2026-03-27 18:42       ` Boqun Feng
2026-03-23  0:15   ` Tamir Duberstein
2026-03-23  0:15     ` Tamir Duberstein
2026-03-19 14:15 ` [PATCH v3 0/4] add `const_assert!` macro and rework documentation Danilo Krummrich
2026-03-29 17:28 ` Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=abwJfsEHd10hqAOb@google.com \
    --to=aliceryhl@google.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=ynorov@nvidia.com \
    --cc=yury.norov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.