Re: [PATCH v3 2/4] rust: add `const_assert!` macro

From: Alice Ryhl

Date: Thu Mar 19 2026 - 10:15:03 EST


On Thu, Mar 19, 2026 at 12:16:46PM +0000, Gary Guo wrote:
> From: Gary Guo <gary@xxxxxxxxxxx>
>
> 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@xxxxxxxxxx>
> Signed-off-by: Gary Guo <gary@xxxxxxxxxxx>

Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>

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