Skip to content

Commit 0a41dfd

Browse files
author
Michael Wright
committed
Use slice patterns instead of padding
1 parent 4e054ad commit 0a41dfd

File tree

1 file changed

+9
-9
lines changed
  • clippy_lints/src/methods

1 file changed

+9
-9
lines changed

clippy_lints/src/methods/mod.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -786,16 +786,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
786786

787787
let (method_names, arg_lists) = method_calls(expr, 2);
788788
let method_names: Vec<LocalInternedString> = method_names.iter().map(|s| s.as_str()).collect();
789-
let mut method_names = method_names.iter().map(|s| s.as_ref()).chain(iter::repeat(""));
789+
let method_names: Vec<&str> = method_names.iter().map(|s| s.as_ref()).collect();
790790

791-
match [method_names.next().unwrap(), method_names.next().unwrap()] {
791+
match method_names.as_slice() {
792792
["unwrap", "get"] => lint_get_unwrap(cx, expr, arg_lists[1], false),
793793
["unwrap", "get_mut"] => lint_get_unwrap(cx, expr, arg_lists[1], true),
794-
["unwrap", _] => lint_unwrap(cx, expr, arg_lists[0]),
794+
["unwrap", ..] => lint_unwrap(cx, expr, arg_lists[0]),
795795
["expect", "ok"] => lint_ok_expect(cx, expr, arg_lists[1]),
796796
["unwrap_or", "map"] => lint_map_unwrap_or(cx, expr, arg_lists[1], arg_lists[0]),
797797
["unwrap_or_else", "map"] => lint_map_unwrap_or_else(cx, expr, arg_lists[1], arg_lists[0]),
798-
["map_or", _] => lint_map_or_none(cx, expr, arg_lists[0]),
798+
["map_or", ..] => lint_map_or_none(cx, expr, arg_lists[0]),
799799
["next", "filter"] => lint_filter_next(cx, expr, arg_lists[1]),
800800
["map", "filter"] => lint_filter_map(cx, expr, arg_lists[1], arg_lists[0]),
801801
["map", "filter_map"] => lint_filter_map_map(cx, expr, arg_lists[1], arg_lists[0]),
@@ -805,16 +805,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
805805
["is_some", "find"] => lint_search_is_some(cx, expr, "find", arg_lists[1], arg_lists[0]),
806806
["is_some", "position"] => lint_search_is_some(cx, expr, "position", arg_lists[1], arg_lists[0]),
807807
["is_some", "rposition"] => lint_search_is_some(cx, expr, "rposition", arg_lists[1], arg_lists[0]),
808-
["extend", _] => lint_extend(cx, expr, arg_lists[0]),
808+
["extend", ..] => lint_extend(cx, expr, arg_lists[0]),
809809
["as_ptr", "unwrap"] => lint_cstring_as_ptr(cx, expr, &arg_lists[1][0], &arg_lists[0][0]),
810810
["nth", "iter"] => lint_iter_nth(cx, expr, arg_lists[1], false),
811811
["nth", "iter_mut"] => lint_iter_nth(cx, expr, arg_lists[1], true),
812812
["next", "skip"] => lint_iter_skip_next(cx, expr),
813813
["collect", "cloned"] => lint_iter_cloned_collect(cx, expr, arg_lists[1]),
814-
["as_ref", _] => lint_asref(cx, expr, "as_ref", arg_lists[0]),
815-
["as_mut", _] => lint_asref(cx, expr, "as_mut", arg_lists[0]),
816-
["fold", _] => lint_unnecessary_fold(cx, expr, arg_lists[0]),
817-
["filter_map", _] => unnecessary_filter_map::lint(cx, expr, arg_lists[0]),
814+
["as_ref", ..] => lint_asref(cx, expr, "as_ref", arg_lists[0]),
815+
["as_mut", ..] => lint_asref(cx, expr, "as_mut", arg_lists[0]),
816+
["fold", ..] => lint_unnecessary_fold(cx, expr, arg_lists[0]),
817+
["filter_map", ..] => unnecessary_filter_map::lint(cx, expr, arg_lists[0]),
818818
_ => {}
819819
}
820820

0 commit comments

Comments
 (0)