@@ -164,17 +164,17 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
164
164
for arm in arms {
165
165
// Check the arm for some things unrelated to exhaustiveness.
166
166
self . check_patterns ( & arm. pat ) ;
167
- if let Some ( hir:: Guard :: IfLet ( ref pat, _) ) = arm. guard {
167
+ if let Some ( hir:: Guard :: IfLet ( ref pat, _, _ ) ) = arm. guard {
168
168
self . check_patterns ( pat) ;
169
169
}
170
170
}
171
171
172
172
let mut cx = self . new_cx ( scrut. hir_id ) ;
173
173
174
174
for arm in arms {
175
- if let Some ( hir:: Guard :: IfLet ( ref pat, _) ) = arm. guard {
175
+ if let Some ( hir:: Guard :: IfLet ( ref pat, _, span ) ) = arm. guard {
176
176
let tpat = self . lower_pattern ( & mut cx, pat, & mut false ) . 0 ;
177
- check_if_let_guard ( & mut cx, & tpat, pat. hir_id ) ;
177
+ check_if_let_guard ( & mut cx, & tpat, pat. hir_id , span ) ;
178
178
}
179
179
}
180
180
@@ -379,7 +379,7 @@ fn irrefutable_let_pattern(tcx: TyCtxt<'_>, span: Span, id: HirId, source: hir::
379
379
diag. help ( "consider instead using a `loop { ... }` with a `let` inside it" ) ;
380
380
diag. emit ( )
381
381
}
382
- hir:: MatchSource :: IfLetGuardDesugar => {
382
+ hir:: MatchSource :: IfLetGuardDesugar { .. } => {
383
383
let mut diag = lint. build ( "irrefutable `if let` guard pattern" ) ;
384
384
diag. note ( "this pattern will always match, so the guard is useless" ) ;
385
385
diag. help ( "consider removing the guard and adding a `let` inside the match arm" ) ;
@@ -398,14 +398,20 @@ fn check_if_let_guard<'p, 'tcx>(
398
398
cx : & mut MatchCheckCtxt < ' p , ' tcx > ,
399
399
pat : & ' p super :: Pat < ' tcx > ,
400
400
pat_id : HirId ,
401
+ let_span : Span ,
401
402
) {
402
403
let arms = [ MatchArm { pat, hir_id : pat_id, has_guard : false } ] ;
403
404
let report = compute_match_usefulness ( & cx, & arms, pat_id, pat. ty ) ;
404
- report_arm_reachability ( & cx, & report, hir:: MatchSource :: IfLetGuardDesugar ) ;
405
+ report_arm_reachability ( & cx, & report, hir:: MatchSource :: IfLetGuardDesugar { let_span } ) ;
405
406
406
407
if report. non_exhaustiveness_witnesses . is_empty ( ) {
407
- // The match is exhaustive, i.e. the `if let` pattern is irrefutable.
408
- irrefutable_let_pattern ( cx. tcx , pat. span , pat_id, hir:: MatchSource :: IfLetGuardDesugar )
408
+ // The match is exhaustive, i.e. the if let pattern is irrefutable.
409
+ irrefutable_let_pattern (
410
+ cx. tcx ,
411
+ let_span,
412
+ pat_id,
413
+ hir:: MatchSource :: IfLetGuardDesugar { let_span } ,
414
+ )
409
415
}
410
416
}
411
417
@@ -435,9 +441,9 @@ fn report_arm_reachability<'p, 'tcx>(
435
441
}
436
442
}
437
443
438
- hir:: MatchSource :: IfLetGuardDesugar => {
444
+ hir:: MatchSource :: IfLetGuardDesugar { let_span } => {
439
445
assert_eq ! ( arm_index, 0 ) ;
440
- unreachable_pattern ( cx. tcx , arm . pat . span , arm. hir_id , None ) ;
446
+ unreachable_pattern ( cx. tcx , let_span , arm. hir_id , None ) ;
441
447
}
442
448
443
449
hir:: MatchSource :: ForLoopDesugar | hir:: MatchSource :: Normal => {
0 commit comments