rust-lang / rust-lang/rust-clippy
`use_debug` lint should not trigger on `debug!()` log macro calls
Open
Nobody has claimed this yet.
C-enhancement
good first issue
T-middle
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Example use-case:
#![cfg_attr(feature = "cargo-clippy", warn(use_debug))]
#[macro_use]
extern crate log;
pub fn euclid_steps(mut x: u64, mut y: u64) -> Vec<u64> {
debug!("x = {}, y = {}", x, y);
let mut steps = vec![];
loop {
let tmp = x % y;
if tmp == 0 {
debug!("Steps performed in Euclidean algorithm: {:?}", steps);
return steps;
}
steps.push(tmp);
x = y;
y = tmp;
}
}
Placing #![cfg_attr(feature = "cargo-clippy", allow(use_debug))] before each debug!() usage seems tedious to me when there are several dozens of them; and turning it off (even if locally) defeats the purpose of the lint.
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 provided example with the use_debug lint enabled and debug!() log macro calls. Trace how the lint identifies debug formatting and determine whether macro calls are being treated as direct debug usage. Done means the lint still catches intended cases without triggering on the shown debug!() calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100