about summary refs log tree commit diff
path: root/src/libstd/macros.rs
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2018-07-14 20:50:30 -0700
committerEsteban Küber <esteban@commure.com>2018-07-19 23:18:07 -0700
commitf53c145ef18db6543e8e5420e172e04b6054db2e (patch)
tree9de9b0c1f029e7dfac14b0ab50181868f46bd9df /src/libstd/macros.rs
parentbc14d71622378cf942a834e7c2b5358b9901f775 (diff)
downloadrust-f53c145ef18db6543e8e5420e172e04b6054db2e.tar.gz
rust-f53c145ef18db6543e8e5420e172e04b6054db2e.zip
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.
Diffstat (limited to 'src/libstd/macros.rs')
-rw-r--r--src/libstd/macros.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs
index 75f038407c1..a4a6ed73c61 100644
--- a/src/libstd/macros.rs
+++ b/src/libstd/macros.rs
@@ -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.