Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbg_macro does not catch invocation inside macro #7274

Closed
gthb opened this issue May 25, 2021 · 0 comments · Fixed by #8411
Closed

dbg_macro does not catch invocation inside macro #7274

gthb opened this issue May 25, 2021 · 0 comments · Fixed by #8411
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@gthb
Copy link

gthb commented May 25, 2021

Lint name: dbg_macro

I tried this code:

pub fn main() {
    // dbg!(1);
    MyThing.foo();
}

trait Thing<'b> {
    fn foo(&self);
}

macro_rules! define_thing {
    ($thing:ident, $body:expr) => {
        impl<'a> Thing<'a> for $thing {
            fn foo<'b>(&self) {
                $body
            }
        }
    };
}

struct MyThing;
define_thing!(MyThing, {
    dbg!(2);
});

I expected to see (by enabling clippy::dbg_macro) a full-throated rejection of that dbg!(2) macro invocation, something like:

$ cargo clippy -- -F clippy::dbg_macro
...
error: `dbg!` macro is intended as a debugging tool
 --> src/main.rs:22:5
  |
22|     dbg!(2);
  |     ^^^^^^^
  |
  = note: requested on the command line with `-F clippy::dbg-macro`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#dbg_macro

... like I do get for the dbg!(1); invocation if I uncomment that.

Instead, I get no clippy warnings/errors.

Meta

  • cargo clippy -V: clippy 0.1.52 (9bc8c42b 2021-05-09)
  • rustc -Vv:
    rustc 1.52.1 (9bc8c42bb 2021-05-09)
    binary: rustc
    commit-hash: 9bc8c42bb2f19e745a63f3445f1ac248fb015e53
    commit-date: 2021-05-09
    host: x86_64-apple-darwin
    release: 1.52.1
    LLVM version: 12.0.0
    
@gthb gthb added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels May 25, 2021
@bors bors closed this as completed in 96c73c5 Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant