Improve suggestion for missing fmt str in println

Avoid using `concat!(fmt, "\n")` to improve the diagnostics being
emitted when the first `println!()` argument isn't a formatting string
literal.
This commit is contained in:
Esteban Küber
2018-07-14 20:50:30 -07:00
committed by Esteban Küber
parent bc14d71622
commit f53c145ef1
14 changed files with 122 additions and 102 deletions

View File

@@ -155,8 +155,14 @@ macro_rules! print {
#[stable(feature = "rust1", since = "1.0.0")]
macro_rules! println {
() => (print!("\n"));
($fmt:expr) => (print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
($fmt:expr) => ({
print!($fmt);
print!("\n");
});
($fmt:expr, $($arg:tt)*) => ({
print!($fmt, $($arg)*);
print!("\n");
});
}
/// Macro for printing to the standard error.