Open
Description
Hello! I'm unsure if this should be an RFC but it seems similar to #57845, so I'll start by filing an issue here.
The problem
Often I end up writing dbg!
code with constant values, usually strings, to trace control flow.
dbg!("Start loop");
while condition {
dbg!("Phase 1");
unsafe { libc::do_something() }
...
dbg!("Phase 2");
...
}
The output is a bit noisier than I'd like.
[lib/emscripten/src/syscalls/unix.rs:826] "Start loop" = "Start loop"
The solution
Detect if the argument to the macro is a literal value (assuming this is possible) and make the output just:
[lib/emscripten/src/syscalls/unix.rs:826] "Start loop"
Alternatives considered:
eprintln!
: doesn't have line and file info. It's a separate macro, so it's less aesthetically pleasing and less intuitive in my opinion.debug!
: usually I'm already using these for other tasks and filtering them out is harder and less convenient thandbg!
;dbg!
is nice because it's explicitly a temporary debugging tool- a custom macro: it'd be nice to be able to use this consistently anywhere
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
Centril commentedon May 25, 2019
This was discussed in https://github.com/rust-lang/rfcs/blob/master/text/2361-dbg-macro.md#outputting-lit--lit-for-dbglit-instead-of-lit.
It is, with
literal
as the matcher, but it becomes hairy with multiple arguments.dbg!()
with no arguments.