about summary refs log tree commit diff
path: root/library/core/src/fmt/rt.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/core/src/fmt/rt.rs')
-rw-r--r--library/core/src/fmt/rt.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/library/core/src/fmt/rt.rs b/library/core/src/fmt/rt.rs
index d27f7e6e0d8..eab48466599 100644
--- a/library/core/src/fmt/rt.rs
+++ b/library/core/src/fmt/rt.rs
@@ -205,8 +205,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] {
         []
     }
 }