Don't allow flattened format_args in const.

This commit is contained in:
Mara Bos
2025-04-10 11:49:08 +02:00
parent 9d28fe3976
commit cc791ebe60

View File

@@ -174,8 +174,15 @@ impl Argument<'_> {
/// let f = format_args!("{}", "a");
/// println!("{f}");
/// ```
///
/// This function should _not_ be const, to make sure we don't accept
/// format_args!() and panic!() with arguments in const, even when not evaluated:
///
/// ```compile_fail,E0015
/// const _: () = if false { panic!("a {}", "a") };
/// ```
#[inline]
pub const fn none() -> [Self; 0] {
pub fn none() -> [Self; 0] {
[]
}
}