about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-05-01 03:18:53 +0000
committerbors <bors@rust-lang.org>2022-05-01 03:18:53 +0000
commit61469b682c2b0bf9cebc4622f1859e2bb3b7ebca (patch)
tree26e9db131d3485e710f899604878d11101cd05c5 /library/std/src
parentbf611439e3239ad3f74bd76cc46a4e89b87d8219 (diff)
parente2d4c7b7c8c28d0b6ed55dc2f8f1aee05e7673d0 (diff)
downloadrust-61469b682c2b0bf9cebc4622f1859e2bb3b7ebca.tar.gz
rust-61469b682c2b0bf9cebc4622f1859e2bb3b7ebca.zip
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:
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/macros.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/library/std/src/macros.rs b/library/std/src/macros.rs
index c597fb5df45..732acaa4186 100644
--- a/library/std/src/macros.rs
+++ b/library/std/src/macros.rs
@@ -99,9 +99,9 @@ macro_rules! println {
     () => {
         $crate::print!("\n")
     };
-    ($($arg:tt)*) => {
-        $crate::io::_print($crate::format_args_nl!($($arg)*))
-    };
+    ($($arg:tt)*) => {{
+        $crate::io::_print($crate::format_args_nl!($($arg)*));
+    }};
 }
 
 /// Prints to the standard error.
@@ -164,9 +164,9 @@ macro_rules! eprintln {
     () => {
         $crate::eprint!("\n")
     };
-    ($($arg:tt)*) => {
-        $crate::io::_eprint($crate::format_args_nl!($($arg)*))
-    };
+    ($($arg:tt)*) => {{
+        $crate::io::_eprint($crate::format_args_nl!($($arg)*));
+    }};
 }
 
 /// Prints and returns the value of a given expression for quick and dirty