Skip to content

Commit 92e25bb

Browse files
committed
Auto merge of #5286 - matthiaskrgr:delay_vec_creation, r=flip1995
check_pat: delay creation of the "normal" vec until we reach the branch where it is actually needed changelog: none
2 parents 118594f + a412b34 commit 92e25bb

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

clippy_lints/src/misc_early.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -318,18 +318,6 @@ impl EarlyLintPass for MiscEarlyLints {
318318
return;
319319
}
320320
if wilds > 0 {
321-
let mut normal = vec![];
322-
323-
for field in pfields {
324-
match field.pat.kind {
325-
PatKind::Wild => {},
326-
_ => {
327-
if let Ok(n) = cx.sess().source_map().span_to_snippet(field.span) {
328-
normal.push(n);
329-
}
330-
},
331-
}
332-
}
333321
for field in pfields {
334322
if let PatKind::Wild = field.pat.kind {
335323
wilds -= 1;
@@ -341,6 +329,19 @@ impl EarlyLintPass for MiscEarlyLints {
341329
"You matched a field with a wildcard pattern. Consider using `..` instead",
342330
);
343331
} else {
332+
let mut normal = vec![];
333+
334+
for field in pfields {
335+
match field.pat.kind {
336+
PatKind::Wild => {},
337+
_ => {
338+
if let Ok(n) = cx.sess().source_map().span_to_snippet(field.span) {
339+
normal.push(n);
340+
}
341+
},
342+
}
343+
}
344+
344345
span_lint_and_help(
345346
cx,
346347
UNNEEDED_FIELD_PATTERN,

0 commit comments

Comments
 (0)