Skip to content

Commit ca05115

Browse files
committed
Auto merge of rust-lang#145882 - m-ou-se:format-args-extend-1-arg, r=petrochenkov
Extended temporary argument to format_args!() in all cases Fixes rust-lang#145880 by removing the special case.
2 parents 0915c6f + a2b5fc1 commit ca05115

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

coretests/tests/fmt/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ fn test_lifetime() {
1212
let a = format_args!("hello {a} {a:?}");
1313
assert_eq!(a.to_string(), "hello hello hello hello hello hello hello");
1414

15+
// Check that temporaries as arguments are extended.
16+
let b = format_args!("{}", String::new());
17+
let c = format_args!("{}{}", String::new(), String::new());
18+
assert_eq!(b.to_string(), "");
19+
assert_eq!(c.to_string(), "");
20+
1521
// Without arguments, it should also work in consts.
1622
const A: std::fmt::Arguments<'static> = format_args!("hello");
1723
assert_eq!(A.to_string(), "hello");

0 commit comments

Comments
 (0)