Skip to content

Commit 1893d46

Browse files
committed
Auto merge of rust-lang#114962 - darklyspaced:debug, r=est31
adds a column number to `dbg!()` this would be very nice to have for a few reasons: 1. the rfc, when deciding not to add column numbers to macro, failed to acknowledge any potential ambiguous cases -- such as the one provided in rust-lang#114910 -- which do exist 2. would be able to consistently and easily jump directly to the `dbg!()` regardless of the sutation 3. takes up, at a maximum, 3 characters of _horizontal_ screen space fixes rust-lang#114910
2 parents 8b4de1b + 1303ff7 commit 1893d46

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

std/src/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,15 @@ macro_rules! dbg {
355355
// `$val` expression could be a block (`{ .. }`), in which case the `eprintln!`
356356
// will be malformed.
357357
() => {
358-
$crate::eprintln!("[{}:{}]", $crate::file!(), $crate::line!())
358+
$crate::eprintln!("[{}:{}:{}]", $crate::file!(), $crate::line!(), $crate::column!())
359359
};
360360
($val:expr $(,)?) => {
361361
// Use of `match` here is intentional because it affects the lifetimes
362362
// of temporaries - https://stackoverflow.com/a/48732525/1063961
363363
match $val {
364364
tmp => {
365-
$crate::eprintln!("[{}:{}] {} = {:#?}",
366-
$crate::file!(), $crate::line!(), $crate::stringify!($val), &tmp);
365+
$crate::eprintln!("[{}:{}:{}] {} = {:#?}",
366+
$crate::file!(), $crate::line!(), $crate::column!(), $crate::stringify!($val), &tmp);
367367
tmp
368368
}
369369
}

0 commit comments

Comments
 (0)