11use rustc:: lint:: { EarlyContext , EarlyLintPass , LintArray , LintPass } ;
22use rustc:: { declare_tool_lint, lint_array} ;
3- use crate :: utils:: span_lint ;
3+ use crate :: utils:: span_lint_and_sugg ;
44use 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/// ```
2122declare_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
4041impl 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 . to_string ( ) , // TODO: to string
52+ Applicability :: MaybeIncorrect ,
4853 ) ;
4954 }
5055 }
0 commit comments