about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-02-15 09:20:16 +0100
committerGitHub <noreply@github.com>2024-02-15 09:20:16 +0100
commit0238d2619fbc99dd707f2761029fc4266617e0a1 (patch)
tree84a8b0b21e1470b3728747e9c235bcf969a08f9c
parentee9c7c940c07d8b67c9a6b2ec930db70dcd23a46 (diff)
parentcd7c161294eac4c2cce5c503f1c5b05ce24864a7 (diff)
downloadrust-0238d2619fbc99dd707f2761029fc4266617e0a1.tar.gz
rust-0238d2619fbc99dd707f2761029fc4266617e0a1.zip
Rollup merge of #111106 - Stargateur:doc/format_args, r=m-ou-se
Add known issue of let binding to format_args doc

Simply add doc about https://github.com/rust-lang/rust/issues/92698.

 `@rustbot` label +T-rustdoc -T-libs

 r? `@GuillaumeGomez`
-rw-r--r--library/core/src/macros/mod.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs
index 9bbaf62a5ca..d818889f364 100644
--- a/library/core/src/macros/mod.rs
+++ b/library/core/src/macros/mod.rs
@@ -969,6 +969,14 @@ pub(crate) mod builtin {
     /// let s = fmt::format(format_args!("hello {}", "world"));
     /// assert_eq!(s, format!("hello {}", "world"));
     /// ```
+    ///
+    /// # Lifetime limitation
+    ///
+    /// Except when no formatting arguments are used,
+    /// the produced `fmt::Arguments` value borrows temporary values,
+    /// which means it can only be used within the same expression
+    /// and cannot be stored for later use.
+    /// This is a known limitation, see [#92698](https://github.com/rust-lang/rust/issues/92698).
     #[stable(feature = "rust1", since = "1.0.0")]
     #[cfg_attr(not(test), rustc_diagnostic_item = "format_args_macro")]
     #[allow_internal_unsafe]