Skip to content

Commit 7ec5528

Browse files
committed
fix category and use suggestion
1 parent f894adc commit 7ec5528

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

clippy_lints/src/dbg_macro.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
22
use rustc::{declare_tool_lint, lint_array};
3-
use crate::utils::span_lint;
3+
use crate::utils::span_lint_and_sugg;
44
use syntax::ast;
5+
use rustc_errors::Applicability;
56

6-
/// **What it does:** Checks for usage of dbg!() macro not to have it in
7-
/// version control.
7+
/// **What it does:** Checks for usage of dbg!() macro.
88
///
9-
/// **Why is this bad?** `dbg!` macro is intended as a debugging tool.
9+
/// **Why is this bad?** `dbg!` macro is intended as a debugging tool. It
10+
/// should not be in version control.
1011
///
1112
/// **Known problems:** None.
1213
///
@@ -20,7 +21,7 @@ use syntax::ast;
2021
/// ```
2122
declare_clippy_lint! {
2223
pub DBG_MACRO,
23-
style,
24+
restriction,
2425
"`dbg!` macro is intended as a debugging tool"
2526
}
2627

@@ -40,11 +41,14 @@ impl LintPass for Pass {
4041
impl EarlyLintPass for Pass {
4142
fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::Mac) {
4243
if mac.node.path == "dbg" {
43-
span_lint(
44+
span_lint_and_sugg(
4445
cx,
4546
DBG_MACRO,
4647
mac.span,
47-
"`dbg!` macro is intended as a debugging tool. ensure to avoid having uses of it in version control",
48+
"`dbg!` macro is intended as a debugging tool",
49+
"ensure to avoid having uses of it in version control",
50+
mac.node.tts.to_string(), // TODO: to string
51+
Applicability::MaybeIncorrect,
4852
);
4953
}
5054
}

tests/ui/dbg_macro.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![warn(clippy::dbg_macro)]
2+
13
fn main() {
24
dbg!(42);
35
}

tests/ui/dbg_macro.stderr

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
error: `dbg!` macro is intended as a debugging tool. ensure to avoid having uses of it in version control
2-
--> $DIR/dbg_macro.rs:2:5
1+
error: `dbg!` macro is intended as a debugging tool
2+
--> $DIR/dbg_macro.rs:4:5
33
|
44
LL | dbg!(42);
55
| ^^^^^^^^
66
|
77
= note: `-D clippy::dbg-macro` implied by `-D warnings`
8+
help: ensure to avoid having uses of it in version control
9+
|
10+
LL | 42;
11+
| ^^
812

913
error: aborting due to previous error
1014

0 commit comments

Comments
 (0)