about summary refs log tree commit diff
path: root/library/coretests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-09-26 04:34:09 +0000
committerbors <bors@rust-lang.org>2025-09-26 04:34:09 +0000
commit40ace17fc3891155bad26a50d60a9ab07b83bf8e (patch)
tree63f2244b43632748b00c3453fd6314e7398e36a8 /library/coretests
parentb733736ea2feb7798c99cbb9a769bce74be108df (diff)
parent663ca24879a6ded2bd1dda8c6da916444f78e850 (diff)
downloadrust-40ace17fc3891155bad26a50d60a9ab07b83bf8e.tar.gz
rust-40ace17fc3891155bad26a50d60a9ab07b83bf8e.zip
Auto merge of #145882 - m-ou-se:format-args-extend-1-arg, r=petrochenkov
Extended temporary argument to format_args!() in all cases

Fixes https://github.com/rust-lang/rust/issues/145880 by removing the special case.
Diffstat (limited to 'library/coretests')
-rw-r--r--library/coretests/tests/fmt/mod.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/library/coretests/tests/fmt/mod.rs b/library/coretests/tests/fmt/mod.rs
index 586e890befe..d0ae7124f47 100644
--- a/library/coretests/tests/fmt/mod.rs
+++ b/library/coretests/tests/fmt/mod.rs
@@ -12,6 +12,12 @@ fn test_lifetime() {
     let a = format_args!("hello {a} {a:?}");
     assert_eq!(a.to_string(), "hello hello hello hello hello hello hello");
 
+    // Check that temporaries as arguments are extended.
+    let b = format_args!("{}", String::new());
+    let c = format_args!("{}{}", String::new(), String::new());
+    assert_eq!(b.to_string(), "");
+    assert_eq!(c.to_string(), "");
+
     // Without arguments, it should also work in consts.
     const A: std::fmt::Arguments<'static> = format_args!("hello");
     assert_eq!(A.to_string(), "hello");