@@ -25,34 +25,20 @@ pub(crate) fn check_if_let<'tcx>(
2525 if !span_contains_comment ( cx. sess ( ) . source_map ( ) , expr. span )
2626 && cx. typeck_results ( ) . expr_ty ( expr) . is_bool ( )
2727 && let Some ( ( None , else_expr) ) = arms. next_back ( )
28- && let arms_without_last = [ ( Some ( let_pat) , then_expr) ]
2928 && let Some ( ( _, first_expr) ) = arms. next ( )
3029 && let Some ( b0) = find_bool_lit ( first_expr)
3130 && let Some ( b1) = find_bool_lit ( else_expr)
3231 && b0 != b1
3332 && arms. all ( |( _, expr) | find_bool_lit ( expr) == Some ( b0) )
3433 {
35- for arm in & arms_without_last {
36- if let Some ( pat) = arm. 0
37- && !is_lint_allowed ( cx, REDUNDANT_PATTERN_MATCHING , pat. hir_id )
38- && is_some_wild ( pat. kind )
39- {
40- return ;
41- }
34+ if !is_lint_allowed ( cx, REDUNDANT_PATTERN_MATCHING , let_pat. hir_id ) && is_some_wild ( let_pat. kind ) {
35+ return ;
4236 }
4337
4438 // The suggestion may be incorrect, because some arms can have `cfg` attributes
4539 // evaluated into `false` and so such arms will be stripped before.
4640 let mut applicability = Applicability :: MaybeIncorrect ;
47- let pat = {
48- use itertools:: Itertools as _;
49- arms_without_last
50- . into_iter ( )
51- . filter_map ( |arm| arm. 0 )
52- . map ( |pat| snippet_with_applicability ( cx, pat. span , ".." , & mut applicability) )
53- . join ( " | " )
54- } ;
55- let pat_and_guard = pat;
41+ let pat = snippet_with_applicability ( cx, let_pat. span , ".." , & mut applicability) ;
5642
5743 // strip potential borrows (#6503), but only if the type is a reference
5844 let mut ex_new = let_expr;
@@ -68,7 +54,7 @@ pub(crate) fn check_if_let<'tcx>(
6854 "if let .. else expression looks like `matches!` macro" ,
6955 "try" ,
7056 format ! (
71- "{}matches!({}, {pat_and_guard })" ,
57+ "{}matches!({}, {pat })" ,
7258 if b0 { "" } else { "!" } ,
7359 snippet_with_applicability( cx, ex_new. span, ".." , & mut applicability) ,
7460 ) ,
0 commit comments