Skip to content

Commit 23966b5

Browse files
committed
Auto merge of #96490 - dtolnay:writetmpbackport, r=Mark-Simulacrum
Make [e]println macros eagerly drop temporaries (for backport) This PR extracts the subset of #96455 which is only the parts necessary for fixing the 1.61-beta regressions in #96434. My larger PR #96455 contains a few other changes relative to the pre-#94868 behavior; those are not necessary to backport into 1.61. argument position | before #94868 | after #94868 | after this PR --- |:---:|:---:|:---: `write!($tmp, "…", …)` | :rage: | :rage: | :rage: `write!(…, "…", $tmp)` | :rage: | :rage: | :rage: `writeln!($tmp, "…", …)` | :rage: | :rage: | :rage: `writeln!(…, "…", $tmp)` | :rage: | :rage: | :rage: `print!("…", $tmp)` | :rage: | :rage: | :rage: `println!("…", $tmp)` | :smiley_cat: | :rage: | :smiley_cat: `eprint!("…", $tmp)` | :rage: | :rage: | :rage: `eprintln!("…", $tmp)` | :smiley_cat: | :rage: | :smiley_cat: `panic!("…", $tmp)` | :smiley_cat: | :smiley_cat: | :smiley_cat:
2 parents 329a57a + 3f17bc6 commit 23966b5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

std/src/macros.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ macro_rules! println {
9999
() => {
100100
$crate::print!("\n")
101101
};
102-
($($arg:tt)*) => {
103-
$crate::io::_print($crate::format_args_nl!($($arg)*))
104-
};
102+
($($arg:tt)*) => {{
103+
$crate::io::_print($crate::format_args_nl!($($arg)*));
104+
}};
105105
}
106106

107107
/// Prints to the standard error.
@@ -164,9 +164,9 @@ macro_rules! eprintln {
164164
() => {
165165
$crate::eprint!("\n")
166166
};
167-
($($arg:tt)*) => {
168-
$crate::io::_eprint($crate::format_args_nl!($($arg)*))
169-
};
167+
($($arg:tt)*) => {{
168+
$crate::io::_eprint($crate::format_args_nl!($($arg)*));
169+
}};
170170
}
171171

172172
/// Prints and returns the value of a given expression for quick and dirty

0 commit comments

Comments
 (0)