Skip to content

Commit 3869e93

Browse files
committed
ignored_unit_patterns: Reorder checks.
1 parent 517e1ac commit 3869e93

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

clippy_lints/src/ignored_unit_patterns.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,21 @@ declare_lint_pass!(IgnoredUnitPatterns => [IGNORED_UNIT_PATTERNS]);
3737

3838
impl<'tcx> LateLintPass<'tcx> for IgnoredUnitPatterns {
3939
fn check_pat(&mut self, cx: &LateContext<'tcx>, pat: &'tcx hir::Pat<'tcx>) {
40-
if pat.span.from_expansion() {
41-
return;
42-
}
43-
44-
match cx.tcx.parent_hir_node(pat.hir_id) {
45-
Node::Param(param) if matches!(cx.tcx.parent_hir_node(param.hir_id), Node::Item(_)) => {
46-
// Ignore function parameters
47-
return;
48-
},
49-
Node::LetStmt(local) if local.ty.is_some() => {
50-
// Ignore let bindings with explicit type
51-
return;
52-
},
53-
_ => {},
54-
}
55-
if matches!(pat.kind, PatKind::Wild) && cx.typeck_results().pat_ty(pat).peel_refs().is_unit() {
40+
if matches!(pat.kind, PatKind::Wild)
41+
&& !pat.span.from_expansion()
42+
&& cx.typeck_results().pat_ty(pat).peel_refs().is_unit()
43+
{
44+
match cx.tcx.parent_hir_node(pat.hir_id) {
45+
Node::Param(param) if matches!(cx.tcx.parent_hir_node(param.hir_id), Node::Item(_)) => {
46+
// Ignore function parameters
47+
return;
48+
},
49+
Node::LetStmt(local) if local.ty.is_some() => {
50+
// Ignore let bindings with explicit type
51+
return;
52+
},
53+
_ => {},
54+
}
5655
span_lint_and_sugg(
5756
cx,
5857
IGNORED_UNIT_PATTERNS,

0 commit comments

Comments
 (0)