@@ -79,7 +79,10 @@ impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, '_, 'tcx> {
79
79
intravisit:: walk_local ( self , loc) ;
80
80
let els = loc. els ;
81
81
if let Some ( init) = loc. init && els. is_some ( ) {
82
- self . check_let ( & loc. pat , init, loc. span ) ;
82
+ // Build a span without the else { ... } as we don't want to underline
83
+ // the entire else block in the IDE setting.
84
+ let span = loc. span . with_hi ( init. span . hi ( ) ) ;
85
+ self . check_let ( & loc. pat , init, span) ;
83
86
}
84
87
85
88
let ( msg, sp) = match loc. source {
@@ -630,11 +633,6 @@ fn irrefutable_let_patterns(
630
633
count : usize ,
631
634
span : Span ,
632
635
) {
633
- let span = match source {
634
- LetSource :: LetElse ( span) => span,
635
- _ => span,
636
- } ;
637
-
638
636
macro_rules! emit_diag {
639
637
(
640
638
$lint: expr,
@@ -680,7 +678,7 @@ fn irrefutable_let_patterns(
680
678
"removing the guard and adding a `let` inside the match arm"
681
679
) ;
682
680
}
683
- LetSource :: LetElse ( .. ) => {
681
+ LetSource :: LetElse => {
684
682
emit_diag ! (
685
683
lint,
686
684
"`let...else`" ,
@@ -1127,7 +1125,7 @@ pub enum LetSource {
1127
1125
GenericLet ,
1128
1126
IfLet ,
1129
1127
IfLetGuard ,
1130
- LetElse ( Span ) ,
1128
+ LetElse ,
1131
1129
WhileLet ,
1132
1130
}
1133
1131
@@ -1156,8 +1154,8 @@ fn let_source_parent(tcx: TyCtxt<'_>, parent: HirId, pat_id: Option<HirId>) -> L
1156
1154
let parent_parent = hir. get_parent_node ( parent) ;
1157
1155
let parent_parent_node = hir. get ( parent_parent) ;
1158
1156
match parent_parent_node {
1159
- hir:: Node :: Stmt ( hir:: Stmt { kind : hir:: StmtKind :: Local ( _) , span , .. } ) => {
1160
- return LetSource :: LetElse ( * span ) ;
1157
+ hir:: Node :: Stmt ( hir:: Stmt { kind : hir:: StmtKind :: Local ( _) , .. } ) => {
1158
+ return LetSource :: LetElse ;
1161
1159
}
1162
1160
hir:: Node :: Arm ( hir:: Arm { guard : Some ( hir:: Guard :: If ( _) ) , .. } ) => {
1163
1161
return LetSource :: IfLetGuard ;
0 commit comments