From: Benno Lossin <benno.lossin@proton.me>
To: Altan Ozlu <altan@ozlu.eu>, Miguel Ojeda <ojeda@kernel.org>,
Alex Gaynor <alex.gaynor@gmail.com>
Cc: "Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v3] rust: static_assert: add optional message
Date: Tue, 25 Mar 2025 22:20:00 +0000 [thread overview]
Message-ID: <D8PP38NJHQ9D.3RPW5BNXLF96L@proton.me> (raw)
In-Reply-To: <20250325211011.1093374-2-altan@ozlu.eu>
On Tue Mar 25, 2025 at 10:10 PM CET, Altan Ozlu wrote:
> Add an optional panic message for `static_assert!` macro.
s/for/to the/
> It doesn't support argument formatting, because currently `assert!`
> doesn't allow formatting in const contextes.
I would make it even more clear:
The panic message doesn't support argument formatting, because the
`assert!` macro only supports formatting in non-const contexts.
>
> Suggested-by: Miguel Ojeda <ojeda@kernel.org>
> Link: https://github.com/Rust-for-Linux/linux/issues/1149
> Signed-off-by: Altan Ozlu <altan@ozlu.eu>
>
> ---
> Link to v2: https://lore.kernel.org/rust-for-linux/20250324210005.990827-2-altan@ozlu.eu/
> ---
> rust/kernel/static_assert.rs | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/rust/kernel/static_assert.rs b/rust/kernel/static_assert.rs
> index 3115ee0ba8e9..b0569dccfb76 100644
> --- a/rust/kernel/static_assert.rs
> +++ b/rust/kernel/static_assert.rs
> @@ -6,6 +6,9 @@
> ///
> /// Similar to C11 [`_Static_assert`] and C++11 [`static_assert`].
> ///
> +/// It supports an optional argument for custom panic messages.
> +/// The panic message doesn't support formatting.
Similarly here I think this fits better:
You can supply an optional panic message after the expression. Currently only a string literal
without formatting is supported due to constness limitations of the [`assert!`] macro.
---
Cheers,
Benno
> +///
> /// The feature may be added to Rust in the future: see [RFC 2790].
> ///
> /// [`_Static_assert`]: https://en.cppreference.com/w/c/language/_Static_assert
prev parent reply other threads:[~2025-03-25 22:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-25 21:10 [PATCH v3] rust: static_assert: add optional message Altan Ozlu
2025-03-25 22:20 ` Benno Lossin [this message]
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=D8PP38NJHQ9D.3RPW5BNXLF96L@proton.me \
--to=benno.lossin@proton.me \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=altan@ozlu.eu \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).