Change:
I just found myself writing only to discover that the macro in fact only prints the source line and not the column of the macro start or something like that :sweatsmile: Is it possible to add the column as well? <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOT_END --
claim
This section from the RFC is quite relevant, : The only exception to this is if the same expression is used multiple times and crucically has side effects altering the value between calls. This scenario is probably uncommon. Furthermore, even in this case, one can visually distinguish between the calls since one is first and the second comes next. we only want to keep the essential parts that help debugging most.
while I agree with the fact that often there is only one debug statement a line, i think that there is one major benefit that the rfc overlooked: users can directly jump to the pertinent debug statement through one unified method regardless of what are used in the statement itself and if multiple share a single line. searching visually is always slower than a hard, concrete jump. additionally, the rfc failed to acknowledge the case above as being an ambiguous situation when using solely line numbers. all this combined with the fact that means that it seems like a pretty sensible addition to the macro.

Discussion:
// `$val` expression could be a block (`{ .. }`), in which case the `eprintln!` // will be malformed. () => { <del> $crate::eprintln!("[{}:{}]", $crate::file!(), $crate::line!()) </del> <ins> $crate::eprintln!("[{}:{}:{}]", $crate::file!(), $crate::line!(), $crate::column!()) </ins> }; ($val:expr $(,)?) => { // Use of `match` here is intentional because it affects the lifetimes // of temporaries - https://stackoverflow.com/a/48732525/1063961 match $val { tmp => { <del> $crate::eprintln!("[{}:{}] {} = {:#?}", $crate::file!(), $crate::line!(), $crate::stringify!($val), &tmp); </del> <ins> $crate::eprintln!("[{}:{}:{}] {} = {:#?}", $crate::file!(), $crate::line!(), $crate::column!(), $crate::stringify!($val), &tmp); </ins> tmp } }

<del> [$DIR/dbg-macro-expected-behavior.rs:22] Unit = Unit [$DIR/dbg-macro-expected-behavior.rs:23] a = Unit [$DIR/dbg-macro-expected-behavior.rs:29] Point { x: 42, y: 24 } = Point { </del> <ins> [$DIR/dbg-macro-expected-behavior.rs:22:19] Unit = Unit [$DIR/dbg-macro-expected-behavior.rs:23:19] a = Unit [$DIR/dbg-macro-expected-behavior.rs:29:24] Point { x: 42, y: 24 } = Point { </ins> x: 42, y: 24, } <del> [$DIR/dbg-macro-expected-behavior.rs:30] b = Point { </del> <ins> [$DIR/dbg-macro-expected-behavior.rs:30:24] b = Point { </ins> x: 42, y: 24, } <del> [$DIR/dbg-macro-expected-behavior.rs:38] [$DIR/dbg-macro-expected-behavior.rs:42] &a = NoCopy( </del> <ins> [$DIR/dbg-macro-expected-behavior.rs:38:17] [$DIR/dbg-macro-expected-behavior.rs:42:27] &a = NoCopy( </ins> 1337, ) <del> [$DIR/dbg-macro-expected-behavior.rs:42] dbg!(&a) = NoCopy( </del> <ins> [$DIR/dbg-macro-expected-behavior.rs:42:22] dbg!(&a) = NoCopy( </ins> 1337, ) <del> [$DIR/dbg-macro-expected-behavior.rs:47] f(&42) = 42 </del> <ins> [$DIR/dbg-macro-expected-behavior.rs:47:18] f(&42) = 42 </ins> before <del> [$DIR/dbg-macro-expected-behavior.rs:52] { foo += 1; eprintln!("before"); 7331 } = 7331 [$DIR/dbg-macro-expected-behavior.rs:60] ("Yeah",) = ( </del> <ins> [$DIR/dbg-macro-expected-behavior.rs:52:22] { foo += 1; eprintln!("before"); 7331 } = 7331 [$DIR/dbg-macro-expected-behavior.rs:60:27] ("Yeah",) = ( </ins> "Yeah", ) <del> [$DIR/dbg-macro-expected-behavior.rs:63] 1 = 1 [$DIR/dbg-macro-expected-behavior.rs:63] 2 = 2 [$DIR/dbg-macro-expected-behavior.rs:67] 1u8 = 1 [$DIR/dbg-macro-expected-behavior.rs:67] 2u32 = 2 [$DIR/dbg-macro-expected-behavior.rs:67] "Yeah" = "Yeah" </del> <ins> [$DIR/dbg-macro-expected-behavior.rs:63:29] 1 = 1 [$DIR/dbg-macro-expected-behavior.rs:63:29] 2 = 2 [$DIR/dbg-macro-expected-behavior.rs:67:37] 1u8 = 1 [$DIR/dbg-macro-expected-behavior.rs:67:37] 2u32 = 2 [$DIR/dbg-macro-expected-behavior.rs:67:37] "Yeah" = "Yeah" </ins>