Skip to content

Commit 5d9aec4

Browse files
committed
work in progress: review comments
1 parent f894adc commit 5d9aec4

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

Diff for: clippy_lints/src/dbg_macro.rs

+12-7
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

@@ -39,12 +40,16 @@ impl LintPass for Pass {
3940

4041
impl EarlyLintPass for Pass {
4142
fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::Mac) {
43+
println!("{:?}", mac);
4244
if mac.node.path == "dbg" {
43-
span_lint(
45+
span_lint_and_sugg(
4446
cx,
4547
DBG_MACRO,
4648
mac.span,
47-
"`dbg!` macro is intended as a debugging tool. ensure to avoid having uses of it in version control",
49+
"`dbg!` macro is intended as a debugging tool",
50+
"ensure to avoid having uses of it in version control",
51+
mac.node.tts, // TODO: to string
52+
Applicability::MaybeIncorrect,
4853
);
4954
}
5055
}

Diff for: tests/ui/dbg_macro.rs

+2
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
}

Diff for: tests/ui/dbg_macro.stderr

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
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 used
2+
--> $DIR/dbg_macro.rs:4:5
33
|
44
LL | dbg!(42);
5-
| ^^^^^^^^
5+
| ^^^^^^^^ help: `dbg!` macro is intended as a debugging tool: `ensure to avoid having uses of it in version control`
66
|
77
= note: `-D clippy::dbg-macro` implied by `-D warnings`
88

9-
error: aborting due to previous error
10-

0 commit comments

Comments
 (0)