Skip to content

Commit f6c3561

Browse files
authored
Rollup merge of #99689 - dtolnay:write, r=Mark-Simulacrum
Revert `write!` and `writeln!` to late drop temporaries Closes (on master, but not on beta) #99684 by reverting the `write!` and `writeln!` parts of #96455. argument position | before<br>#94868 | after<br>#94868 | after<br>#96455 | after<br>this PR | desired<br>(unimplementable) --- |:---:|:---:|:---:|:---:|:---: `write!($tmp, "…", …)` | **⸺late** | **⸺late** | *early⸺* | **⸺late** | **⸺late** `write!(…, "…", $tmp)` | **⸺late** | **⸺late** | *early⸺* | **⸺late** | *early⸺* `writeln!($tmp, "…", …)` | **⸺late** | **⸺late** | *early⸺* | **⸺late** | **⸺late** `writeln!(…, "…", $tmp)` | **⸺late** | **⸺late** | *early⸺* | **⸺late** | *early⸺* `print!("…", $tmp)` | **⸺late** | **⸺late** | *early⸺* | *early⸺* | *early⸺* `println!("…", $tmp)` | *early⸺* | **⸺late** | *early⸺* | *early⸺* | *early⸺* `eprint!("…", $tmp)` | **⸺late** | **⸺late** | *early⸺* | *early⸺* | *early⸺* `eprintln!("…", $tmp)` | *early⸺* | **⸺late**| *early⸺* | *early⸺* | *early⸺* `panic!("…", $tmp)` | *early⸺* | *early⸺* | *early⸺* | *early⸺* | *early⸺* "Late drop" refers to dropping temporaries at the nearest semicolon **outside** of the macro invocation. "Early drop" refers to dropping temporaries inside of the macro invocation.
2 parents 52f3326 + 052fb9d commit f6c3561

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

core/src/macros/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,9 @@ macro_rules! r#try {
496496
#[stable(feature = "rust1", since = "1.0.0")]
497497
#[cfg_attr(not(test), rustc_diagnostic_item = "write_macro")]
498498
macro_rules! write {
499-
($dst:expr, $($arg:tt)*) => {{
500-
let result = $dst.write_fmt($crate::format_args!($($arg)*));
501-
result
502-
}};
499+
($dst:expr, $($arg:tt)*) => {
500+
$dst.write_fmt($crate::format_args!($($arg)*))
501+
};
503502
}
504503

505504
/// Write formatted data into a buffer, with a newline appended.
@@ -554,10 +553,9 @@ macro_rules! writeln {
554553
($dst:expr $(,)?) => {
555554
$crate::write!($dst, "\n")
556555
};
557-
($dst:expr, $($arg:tt)*) => {{
558-
let result = $dst.write_fmt($crate::format_args_nl!($($arg)*));
559-
result
560-
}};
556+
($dst:expr, $($arg:tt)*) => {
557+
$dst.write_fmt($crate::format_args_nl!($($arg)*))
558+
};
561559
}
562560

563561
/// Indicates unreachable code.

0 commit comments

Comments
 (0)