Skip to contentSkip to conversation

rust: static_assert: add optional message

PATCH Benno Lossin 1 participant 1 message Mar 24, 2025 Rust

lore
Share & tools
lore
#0 lore raw
Quoted 1 line · Altan Ozlu

Add optional panic message for static_assert! macro.

s/Add/Add an/

Quoted 3 lines

It doesn't support argument formatting, due to const_format_args being experimental. It will fail to compile if a message with argument is given.

I don't think that this is the correct reason to give why it's not supported. As you mentioned in another mail, the feature is a compiler-internal feature and is not intended to be stabilized. Yes the error reported by the compiler references the const_format_args macro, but that's an implementation detail of assert, so I wouldn't put too much weight into it.

Instead I would just say that assert! doesn't yet support formatting in const contexts (maybe also add that to the documentation, so someone will complain when that's been implemented and it flew under our radar).

Quoted 3 lines

Usually when sending a new version of a patch, you don't send it in reply to the previous version.

---
Cheers,
Benno

Quoted 3 lines
---
 rust/kernel/static_assert.rs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)