@@ -164,17 +164,17 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
164164 for arm in arms {
165165 // Check the arm for some things unrelated to exhaustiveness.
166166 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 {
168168 self . check_patterns ( pat) ;
169169 }
170170 }
171171
172172 let mut cx = self . new_cx ( scrut. hir_id ) ;
173173
174174 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 {
176176 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 ) ;
178178 }
179179 }
180180
@@ -379,7 +379,7 @@ fn irrefutable_let_pattern(tcx: TyCtxt<'_>, span: Span, id: HirId, source: hir::
379379 diag. help ( "consider instead using a `loop { ... }` with a `let` inside it" ) ;
380380 diag. emit ( )
381381 }
382- hir:: MatchSource :: IfLetGuardDesugar => {
382+ hir:: MatchSource :: IfLetGuardDesugar { .. } => {
383383 let mut diag = lint. build ( "irrefutable `if let` guard pattern" ) ;
384384 diag. note ( "this pattern will always match, so the guard is useless" ) ;
385385 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>(
398398 cx : & mut MatchCheckCtxt < ' p , ' tcx > ,
399399 pat : & ' p super :: Pat < ' tcx > ,
400400 pat_id : HirId ,
401+ let_span : Span ,
401402) {
402403 let arms = [ MatchArm { pat, hir_id : pat_id, has_guard : false } ] ;
403404 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 } ) ;
405406
406407 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+ )
409415 }
410416}
411417
@@ -435,9 +441,9 @@ fn report_arm_reachability<'p, 'tcx>(
435441 }
436442 }
437443
438- hir:: MatchSource :: IfLetGuardDesugar => {
444+ hir:: MatchSource :: IfLetGuardDesugar { let_span } => {
439445 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 ) ;
441447 }
442448
443449 hir:: MatchSource :: ForLoopDesugar | hir:: MatchSource :: Normal => {
0 commit comments