rust-lang / rust-lang/rust-clippy
`dbg_macro` suggestions are questionable
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
dbg_macro suggests to remove the dbg! macros in your code. I love the idea of this lint! but seems like it just removes the dbg! macro. Nothing more.
This means that the suggestion about dbg!(X) will be to convert it to X. Does this even make sense?
imo the suggestion shouldn't be to just remove the dbg! macro leaving the contents, but to remove the macro and the contents.
Reproducer
#[warn(clippy::dbg_macro)]
fn main() {
dbg!("Hi");
}
This should be converted to:
#[warn(clippy::dbg_macro)]
fn main() {}
Instead, applying the suggestion does this:
#[warn(clippy::dbg_macro)]
fn main() {
"Hi";
}
Which makes no sense.
Version
rustc 1.71.0-nightly (9ecda8de8 2023-04-30)
binary: rustc
commit-hash: 9ecda8de85ce893cc3fc748ab06be0b8250147a7
commit-date: 2023-04-30
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2
Additional Labels
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the Rust snippet in the report, then locate the dbg_macro lint and its suggestion handling. Add or update a regression test for dbg!("Hi") and verify that applying the suggestion removes both the macro and its contents rather than leaving a standalone expression.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100