rust-lang / rust-lang/rust-clippy

`use_debug` does not work for `format_args!()`

Open
#8,027 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug C-enhancement
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Lint name: use_debug

I tried this code:

fn main() {
    format_args!("{:?}", "Hello, world!");
}

I expected to see this happen: the lint should fail, because I am using debug formatting. Actually I am using the log crate and was surprised, that I do not get a warning from clippy. I am just guessing that fixing this for format_args!() also will fix the log!() macros that internally depend on it.

Meta

Rust version (rustc -Vv):

rustc 1.58.0-nightly (936f2600b 2021-11-22)
binary: rustc
commit-hash: 936f2600b6c903b04387f74ed5cbce88bb06d243
commit-date: 2021-11-22
host: x86_64-unknown-linux-gnu
release: 1.58.0-nightly
LLVM version: 13.0.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the provided format_args! example and then trace the use_debug lint entry point in rust-clippy. Check whether the lint sees debug formatting inside format_args! and verify that the expected warning also covers the reported logging-macro case.

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
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.