@@ -190,7 +190,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
190
190
let scrut_ty = self . typeck_results . expr_ty_adjusted ( scrut) ;
191
191
let report = compute_match_usefulness ( & cx, & arms, scrut. hir_id , scrut_ty) ;
192
192
193
- report_arm_reachability ( & cx, & report, |_ , arm_span, arm_hir_id, catchall| {
193
+ report_arm_reachability ( & cx, & report, |arm_span, arm_hir_id, catchall| {
194
194
match source {
195
195
hir:: MatchSource :: ForLoopDesugar | hir:: MatchSource :: Normal => {
196
196
unreachable_pattern ( cx. tcx , arm_span, arm_hir_id, catchall) ;
@@ -434,23 +434,14 @@ fn check_let_reachability<'p, 'tcx>(
434
434
let arms = [ MatchArm { pat, hir_id : pat_id, has_guard : false } ] ;
435
435
let report = compute_match_usefulness ( & cx, & arms, pat_id, pat. ty ) ;
436
436
437
- report_arm_reachability ( & cx, & report, |arm_index, arm_span, arm_hir_id, _| {
438
- match let_source ( cx. tcx , pat_id) {
439
- LetSource :: IfLet | LetSource :: WhileLet => {
440
- match arm_index {
441
- // The arm with the user-specified pattern.
442
- 0 => unreachable_pattern ( cx. tcx , arm_span, arm_hir_id, None ) ,
443
- // The arm with the wildcard pattern.
444
- 1 => irrefutable_let_pattern ( cx. tcx , pat_id, arm_span) ,
445
- _ => bug ! ( ) ,
446
- }
447
- }
448
- LetSource :: IfLetGuard if arm_index == 0 => {
449
- unreachable_pattern ( cx. tcx , arm_span, arm_hir_id, None ) ;
450
- }
451
- _ => { }
437
+ match let_source ( cx. tcx , pat_id) {
438
+ LetSource :: IfLet | LetSource :: WhileLet | LetSource :: IfLetGuard => {
439
+ report_arm_reachability ( & cx, & report, |arm_span, arm_hir_id, _| {
440
+ unreachable_pattern ( cx. tcx , arm_span, arm_hir_id, None )
441
+ } ) ;
452
442
}
453
- } ) ;
443
+ _ => { }
444
+ }
454
445
455
446
if report. non_exhaustiveness_witnesses . is_empty ( ) {
456
447
// The match is exhaustive, i.e. the `if let` pattern is irrefutable.
@@ -464,13 +455,13 @@ fn report_arm_reachability<'p, 'tcx, F>(
464
455
report : & UsefulnessReport < ' p , ' tcx > ,
465
456
unreachable : F ,
466
457
) where
467
- F : Fn ( usize , Span , HirId , Option < Span > ) ,
458
+ F : Fn ( Span , HirId , Option < Span > ) ,
468
459
{
469
460
use Reachability :: * ;
470
461
let mut catchall = None ;
471
- for ( arm_index , ( arm, is_useful) ) in report. arm_usefulness . iter ( ) . enumerate ( ) {
462
+ for ( arm, is_useful) in report. arm_usefulness . iter ( ) {
472
463
match is_useful {
473
- Unreachable => unreachable ( arm_index , arm. pat . span , arm. hir_id , catchall) ,
464
+ Unreachable => unreachable ( arm. pat . span , arm. hir_id , catchall) ,
474
465
Reachable ( unreachables) if unreachables. is_empty ( ) => { }
475
466
// The arm is reachable, but contains unreachable subpatterns (from or-patterns).
476
467
Reachable ( unreachables) => {
0 commit comments