diff options
Diffstat (limited to 'library/core/src/fmt/rt.rs')
-rw-r--r-- | library/core/src/fmt/rt.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/library/core/src/fmt/rt.rs b/library/core/src/fmt/rt.rs index 0596f6c30ce..d37888c27bd 100644 --- a/library/core/src/fmt/rt.rs +++ b/library/core/src/fmt/rt.rs @@ -152,6 +152,21 @@ impl<'a> Argument<'a> { None } } + + /// Used by `format_args` when all arguments are gone after inlining, + /// when using `&[]` would incorrectly allow for a bigger lifetime. + /// + /// This fails without format argument inlining, and that shouldn't be different + /// when the argument is inlined: + /// + /// ```compile_fail,E0716 + /// let f = format_args!("{}", "a"); + /// println!("{f}"); + /// ``` + #[inline(always)] + pub fn none() -> [Self; 0] { + [] + } } /// This struct represents the unsafety of constructing an `Arguments`. |