@@ -175,7 +175,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
175
175
}
176
176
177
177
// Fourth, check for unreachable arms.
178
- check_arms ( cx, & inlined_arms, source) ;
178
+ let matrix = check_arms ( cx, & inlined_arms, source) ;
179
179
180
180
// Then, if the match has no arms, check whether the scrutinee
181
181
// is uninhabited.
@@ -242,12 +242,6 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
242
242
return ;
243
243
}
244
244
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 ( ) ;
251
245
let scrut_ty = self . tables . node_type ( scrut. hir_id ) ;
252
246
check_exhaustive ( cx, scrut_ty, scrut. span , & matrix) ;
253
247
} )
@@ -397,11 +391,11 @@ fn pat_is_catchall(pat: &Pat) -> bool {
397
391
}
398
392
399
393
// Check for unreachable patterns
400
- fn check_arms < ' tcx > (
394
+ fn check_arms < ' p , ' tcx > (
401
395
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 > ) ] ,
403
397
source : hir:: MatchSource ,
404
- ) {
398
+ ) -> Matrix < ' p , ' tcx > {
405
399
let mut seen = Matrix :: empty ( ) ;
406
400
let mut catchall = None ;
407
401
for ( arm_index, & ( ref pats, guard) ) in arms. iter ( ) . enumerate ( ) {
@@ -479,6 +473,7 @@ fn check_arms<'tcx>(
479
473
}
480
474
}
481
475
}
476
+ seen
482
477
}
483
478
484
479
fn check_not_useful (
0 commit comments