]> git.lizzy.rs Git - rust.git/commitdiff
fix category and use suggestion
authorrhysd <lin90162@yahoo.co.jp>
Fri, 1 Feb 2019 00:23:40 +0000 (09:23 +0900)
committerrhysd <lin90162@yahoo.co.jp>
Fri, 1 Feb 2019 00:31:26 +0000 (09:31 +0900)
clippy_lints/src/dbg_macro.rs
tests/ui/dbg_macro.rs
tests/ui/dbg_macro.stderr

index fad012bf7a2562e0e0f2f50174e4bc5b7594b493..3dce8189b71146e227dcaed29444f807688b152d 100644 (file)
@@ -1,12 +1,13 @@
 use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
 use rustc::{declare_tool_lint, lint_array};
-use crate::utils::span_lint;
+use crate::utils::span_lint_and_sugg;
 use syntax::ast;
+use rustc_errors::Applicability;
 
-/// **What it does:** Checks for usage of dbg!() macro not to have it in
-/// version control.
+/// **What it does:** Checks for usage of dbg!() macro.
 ///
-/// **Why is this bad?** `dbg!` macro is intended as a debugging tool.
+/// **Why is this bad?** `dbg!` macro is intended as a debugging tool. It
+/// should not be in version control.
 ///
 /// **Known problems:** None.
 ///
@@ -20,7 +21,7 @@
 /// ```
 declare_clippy_lint! {
     pub DBG_MACRO,
-    style,
+    restriction,
     "`dbg!` macro is intended as a debugging tool"
 }
 
@@ -40,11 +41,14 @@ fn name(&self) -> &'static str {
 impl EarlyLintPass for Pass {
     fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::Mac) {
         if mac.node.path == "dbg" {
-            span_lint(
+            span_lint_and_sugg(
                 cx,
                 DBG_MACRO,
                 mac.span,
-                "`dbg!` macro is intended as a debugging tool. ensure to avoid having uses of it in version control",
+                "`dbg!` macro is intended as a debugging tool",
+                "ensure to avoid having uses of it in version control",
+                mac.node.tts.to_string(), // TODO: to string
+                Applicability::MaybeIncorrect,
             );
         }
     }
index cf113050c2671cc832318bd5e9fa90a6e33ad248..dc96c7da0ace74884f37f1d0d1d323ef0e936e79 100644 (file)
@@ -1,3 +1,5 @@
+#![warn(clippy::dbg_macro)]
+
 fn main() {
     dbg!(42);
 }
index cb5389c6e765c13f174b05bb373446e300a943b7..4b8501462ff5461e7195b5a3ebb1159bffa26eb5 100644 (file)
@@ -1,10 +1,14 @@
-error: `dbg!` macro is intended as a debugging tool. ensure to avoid having uses of it in version control
-  --> $DIR/dbg_macro.rs:2:5
+error: `dbg!` macro is intended as a debugging tool
+  --> $DIR/dbg_macro.rs:4:5
    |
 LL |     dbg!(42);
    |     ^^^^^^^^
    |
    = note: `-D clippy::dbg-macro` implied by `-D warnings`
+help: ensure to avoid having uses of it in version control
+   |
+LL |     42;
+   |     ^^
 
 error: aborting due to previous error