Skip to content

use_debug lint should not trigger on debug!() log macro calls #2132

Open
@hcpl

Description

@hcpl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesT-middleType: Probably requires verifiying typesgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions