Make write/print macros eagerly drop temporaries
This commit is contained in:
parent
ae29890ab6
commit
0502496b1e
2 changed files with 14 additions and 12 deletions
|
@ -496,9 +496,10 @@ macro_rules! r#try {
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[cfg_attr(not(test), rustc_diagnostic_item = "write_macro")]
|
#[cfg_attr(not(test), rustc_diagnostic_item = "write_macro")]
|
||||||
macro_rules! write {
|
macro_rules! write {
|
||||||
($dst:expr, $($arg:tt)*) => {
|
($dst:expr, $($arg:tt)*) => {{
|
||||||
$dst.write_fmt($crate::format_args!($($arg)*))
|
let result = $dst.write_fmt($crate::format_args!($($arg)*));
|
||||||
};
|
result
|
||||||
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write formatted data into a buffer, with a newline appended.
|
/// Write formatted data into a buffer, with a newline appended.
|
||||||
|
@ -553,9 +554,10 @@ macro_rules! writeln {
|
||||||
($dst:expr $(,)?) => {
|
($dst:expr $(,)?) => {
|
||||||
$crate::write!($dst, "\n")
|
$crate::write!($dst, "\n")
|
||||||
};
|
};
|
||||||
($dst:expr, $($arg:tt)*) => {
|
($dst:expr, $($arg:tt)*) => {{
|
||||||
$dst.write_fmt($crate::format_args_nl!($($arg)*))
|
let result = $dst.write_fmt($crate::format_args_nl!($($arg)*));
|
||||||
};
|
result
|
||||||
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Indicates unreachable code.
|
/// Indicates unreachable code.
|
||||||
|
|
|
@ -62,9 +62,9 @@ macro_rules! panic {
|
||||||
#[cfg_attr(not(test), rustc_diagnostic_item = "print_macro")]
|
#[cfg_attr(not(test), rustc_diagnostic_item = "print_macro")]
|
||||||
#[allow_internal_unstable(print_internals)]
|
#[allow_internal_unstable(print_internals)]
|
||||||
macro_rules! print {
|
macro_rules! print {
|
||||||
($($arg:tt)*) => {
|
($($arg:tt)*) => {{
|
||||||
$crate::io::_print($crate::format_args!($($arg)*))
|
$crate::io::_print($crate::format_args!($($arg)*));
|
||||||
};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prints to the standard output, with a newline.
|
/// Prints to the standard output, with a newline.
|
||||||
|
@ -133,9 +133,9 @@ macro_rules! println {
|
||||||
#[cfg_attr(not(test), rustc_diagnostic_item = "eprint_macro")]
|
#[cfg_attr(not(test), rustc_diagnostic_item = "eprint_macro")]
|
||||||
#[allow_internal_unstable(print_internals)]
|
#[allow_internal_unstable(print_internals)]
|
||||||
macro_rules! eprint {
|
macro_rules! eprint {
|
||||||
($($arg:tt)*) => {
|
($($arg:tt)*) => {{
|
||||||
$crate::io::_eprint($crate::format_args!($($arg)*))
|
$crate::io::_eprint($crate::format_args!($($arg)*));
|
||||||
};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prints to the standard error, with a newline.
|
/// Prints to the standard error, with a newline.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue