-fn check_match_ref_pats(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: &Expr<'_>) {
- if has_only_ref_pats(arms) {
- let mut suggs = Vec::with_capacity(arms.len() + 1);
- let (title, msg) = if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = ex.kind {
- let span = ex.span.source_callsite();
- suggs.push((span, Sugg::hir_with_macro_callsite(cx, inner, "..").to_string()));
- (
- "you don't need to add `&` to both the expression and the patterns",
- "try",
- )
- } else {
- let span = ex.span.source_callsite();
- suggs.push((span, Sugg::hir_with_macro_callsite(cx, ex, "..").deref().to_string()));
- (
- "you don't need to add `&` to all patterns",
- "instead of prefixing all patterns with `&`, you can dereference the expression",
- )
- };
-
- suggs.extend(arms.iter().filter_map(|a| {
- if let PatKind::Ref(refp, _) = a.pat.kind {
- Some((a.pat.span, snippet(cx, refp.span, "..").to_string()))
- } else {
- None
- }
- }));
+fn check_match_ref_pats<'a, 'b, I>(cx: &LateContext<'_>, ex: &Expr<'_>, pats: I, expr: &Expr<'_>)
+where
+ 'b: 'a,
+ I: Clone + Iterator<Item = &'a Pat<'b>>,
+{
+ if !has_only_ref_pats(pats.clone()) {
+ return;
+ }