about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-03-19 15:16:46 +0100
committerGitHub <noreply@github.com>2019-03-19 15:16:46 +0100
commitd4ef74b2daab3119e34e2dbed6bb2ab40b49cae9 (patch)
treeb82f9d1975bfffa209df981ced4e12cc02360a87 /src/libstd
parentc1975dbd34a69565cd0a66770377ed9bfc85fa35 (diff)
parentea9e2c4ef5cf2d1867b284bd4f84b5417d8df45b (diff)
downloadrust-d4ef74b2daab3119e34e2dbed6bb2ab40b49cae9.tar.gz
rust-d4ef74b2daab3119e34e2dbed6bb2ab40b49cae9.zip
Rollup merge of #57847 - clarcharr:dbg_no_params, r=Centril
dbg!() without parameters

Fixes #57845.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/macros.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs
index 9d0eb2e6b1c..d5dc5f7c4f0 100644
--- a/src/libstd/macros.rs
+++ b/src/libstd/macros.rs
@@ -305,10 +305,16 @@ macro_rules! eprintln {
 /// let _ = dbg!(a); // <-- `a` is moved again; error!
 /// ```
 ///
+/// You can also use `dbg!()` without a value to just print the
+/// file and line whenever it's reached.
+///
 /// [stderr]: https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)
 #[macro_export]
 #[stable(feature = "dbg_macro", since = "1.32.0")]
 macro_rules! dbg {
+    () => {
+        eprintln!("[{}:{}]", file!(), line!());
+    };
     ($val:expr) => {
         // Use of `match` here is intentional because it affects the lifetimes
         // of temporaries - https://stackoverflow.com/a/48732525/1063961