Skip to content

Commit 60f723f

Browse files
committed
prefer if to match
1 parent 3100fec commit 60f723f

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

clippy_lints/src/dbg_macro.rs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,25 @@ impl LintPass for Pass {
4343
impl EarlyLintPass for Pass {
4444
fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::Mac) {
4545
if mac.node.path == "dbg" {
46-
match tts_span(mac.node.tts.clone()).and_then(|span| snippet_opt(cx, span)) {
47-
Some(sugg) => {
48-
span_lint_and_sugg(
49-
cx,
50-
DBG_MACRO,
51-
mac.span,
52-
"`dbg!` macro is intended as a debugging tool",
53-
"ensure to avoid having uses of it in version control",
54-
sugg,
55-
Applicability::MaybeIncorrect,
56-
);
57-
}
58-
None => {
59-
span_help_and_lint(
60-
cx,
61-
DBG_MACRO,
62-
mac.span,
63-
"`dbg!` macro is intended as a debugging tool",
64-
"ensure to avoid having uses of it in version control",
65-
);
66-
}
67-
};
46+
if let Some(sugg) = tts_span(mac.node.tts.clone()).and_then(|span| snippet_opt(cx, span)) {
47+
span_lint_and_sugg(
48+
cx,
49+
DBG_MACRO,
50+
mac.span,
51+
"`dbg!` macro is intended as a debugging tool",
52+
"ensure to avoid having uses of it in version control",
53+
sugg,
54+
Applicability::MaybeIncorrect,
55+
);
56+
} else {
57+
span_help_and_lint(
58+
cx,
59+
DBG_MACRO,
60+
mac.span,
61+
"`dbg!` macro is intended as a debugging tool",
62+
"ensure to avoid having uses of it in version control",
63+
);
64+
}
6865
}
6966
}
7067
}

0 commit comments

Comments
 (0)