Skip to content

Commit 99be522

Browse files
author
Michael Wright
committed
Apply review suggestions
Fix grammar errors and use `Pat::is_rest` instead of own function.
1 parent 00ca42f commit 99be522

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

clippy_lints/src/misc_early.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ declare_clippy_lint! {
197197

198198
declare_clippy_lint! {
199199
/// **What it does:** Checks for tuple patterns with a wildcard
200-
/// pattern (`_`) is next to a rest pattern (`..`) pattern.
200+
/// pattern (`_`) is next to a rest pattern (`..`).
201201
///
202202
/// **Why is this bad?** The wildcard pattern is unneeded as the rest pattern
203203
/// can match that element as well.
@@ -226,7 +226,7 @@ declare_clippy_lint! {
226226
/// ```
227227
pub UNNEEDED_WILDCARD_PATTERN,
228228
complexity,
229-
"tuple patterns with a wildcard pattern (`_`) is next to a rest pattern (`..`) pattern"
229+
"tuple patterns with a wildcard pattern (`_`) is next to a rest pattern (`..`)"
230230
}
231231

232232
declare_lint_pass!(MiscEarlyLints => [
@@ -576,14 +576,6 @@ fn check_unneeded_wildcard_pattern(cx: &EarlyContext<'_>, pat: &Pat) {
576576
);
577577
}
578578

579-
fn is_rest<P: std::ops::Deref<Target = Pat>>(pat: &P) -> bool {
580-
if let PatKind::Rest = pat.node {
581-
true
582-
} else {
583-
false
584-
}
585-
}
586-
587579
#[allow(clippy::trivially_copy_pass_by_ref)]
588580
fn is_wild<P: std::ops::Deref<Target = Pat>>(pat: &&P) -> bool {
589581
if let PatKind::Wild = pat.node {
@@ -593,7 +585,7 @@ fn check_unneeded_wildcard_pattern(cx: &EarlyContext<'_>, pat: &Pat) {
593585
}
594586
}
595587

596-
if let Some(rest_index) = patterns.iter().position(is_rest) {
588+
if let Some(rest_index) = patterns.iter().position(|pat| pat.is_rest()) {
597589
if let Some((left_index, left_pat)) = patterns[..rest_index]
598590
.iter()
599591
.rev()

0 commit comments

Comments
 (0)