diff options
| author | rhysd <lin90162@yahoo.co.jp> | 2019-02-03 18:50:00 +0900 |
|---|---|---|
| committer | rhysd <lin90162@yahoo.co.jp> | 2019-02-03 18:50:00 +0900 |
| commit | 60f723fba42756138f3a9386b8376e2ed3e7dda1 (patch) | |
| tree | 437fb8ae42a233d19233899d8ded018fc5b981bb | |
| parent | 3100fecb99782941a2512d58e7021fd93a57b619 (diff) | |
| download | rust-60f723fba42756138f3a9386b8376e2ed3e7dda1.tar.gz rust-60f723fba42756138f3a9386b8376e2ed3e7dda1.zip | |
prefer `if` to `match`
| -rw-r--r-- | clippy_lints/src/dbg_macro.rs | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/clippy_lints/src/dbg_macro.rs b/clippy_lints/src/dbg_macro.rs index 228d31bd554..ae551a0792d 100644 --- a/clippy_lints/src/dbg_macro.rs +++ b/clippy_lints/src/dbg_macro.rs @@ -43,28 +43,25 @@ impl LintPass for Pass { impl EarlyLintPass for Pass { fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::Mac) { if mac.node.path == "dbg" { - match tts_span(mac.node.tts.clone()).and_then(|span| snippet_opt(cx, span)) { - Some(sugg) => { - 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", - sugg, - Applicability::MaybeIncorrect, - ); - } - None => { - span_help_and_lint( - cx, - DBG_MACRO, - mac.span, - "`dbg!` macro is intended as a debugging tool", - "ensure to avoid having uses of it in version control", - ); - } - }; + if let Some(sugg) = tts_span(mac.node.tts.clone()).and_then(|span| snippet_opt(cx, span)) { + 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", + sugg, + Applicability::MaybeIncorrect, + ); + } else { + span_help_and_lint( + cx, + DBG_MACRO, + mac.span, + "`dbg!` macro is intended as a debugging tool", + "ensure to avoid having uses of it in version control", + ); + } } } } |
