@@ -175,7 +175,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
175175 }
176176
177177 // Fourth, check for unreachable arms.
178- check_arms ( cx, & inlined_arms, source) ;
178+ let matrix = check_arms ( cx, & inlined_arms, source) ;
179179
180180 // Then, if the match has no arms, check whether the scrutinee
181181 // is uninhabited.
@@ -242,12 +242,6 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
242242 return ;
243243 }
244244
245- let matrix: Matrix < ' _ , ' _ > = inlined_arms
246- . iter ( )
247- . filter ( |& & ( _, guard) | guard. is_none ( ) )
248- . flat_map ( |arm| & arm. 0 )
249- . map ( |pat| PatStack :: from_pattern ( cx, pat. 0 ) )
250- . collect ( ) ;
251245 let scrut_ty = self . tables . node_type ( scrut. hir_id ) ;
252246 check_exhaustive ( cx, scrut_ty, scrut. span , & matrix) ;
253247 } )
@@ -397,11 +391,11 @@ fn pat_is_catchall(pat: &Pat) -> bool {
397391}
398392
399393// Check for unreachable patterns
400- fn check_arms < ' tcx > (
394+ fn check_arms < ' p , ' tcx > (
401395 cx : & mut MatchCheckCtxt < ' _ , ' tcx > ,
402- arms : & [ ( Vec < ( & super :: Pat < ' tcx > , & hir:: Pat ) > , Option < & hir:: Expr > ) ] ,
396+ arms : & [ ( Vec < ( & ' p super :: Pat < ' tcx > , & hir:: Pat ) > , Option < & hir:: Expr > ) ] ,
403397 source : hir:: MatchSource ,
404- ) {
398+ ) -> Matrix < ' p , ' tcx > {
405399 let mut seen = Matrix :: empty ( ) ;
406400 let mut catchall = None ;
407401 for ( arm_index, & ( ref pats, guard) ) in arms. iter ( ) . enumerate ( ) {
@@ -479,6 +473,7 @@ fn check_arms<'tcx>(
479473 }
480474 }
481475 }
476+ seen
482477}
483478
484479fn check_not_useful (
0 commit comments