Skip to content

Commit 6fb5b73

Browse files
author
Clar Fon
committed
dbg!() without parameters.
1 parent 9690917 commit 6fb5b73

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libstd/macros.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,16 @@ macro_rules! eprintln {
305305
/// let _ = dbg!(a); // <-- `a` is moved again; error!
306306
/// ```
307307
///
308+
/// You can also use `dbg!()` without a value to just print the
309+
/// file and line whenever it's reached.
310+
///
308311
/// [stderr]: https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)
309312
#[macro_export]
310313
#[stable(feature = "dbg_macro", since = "1.32.0")]
311314
macro_rules! dbg {
315+
() => {
316+
eprintln!("[{}:{}]", file!(), line!());
317+
};
312318
($val:expr) => {
313319
// Use of `match` here is intentional because it affects the lifetimes
314320
// of temporaries - https://stackoverflow.com/a/48732525/1063961

0 commit comments

Comments
 (0)