@@ -607,9 +607,10 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
607607 }
608608
609609 fn check_local ( & mut self , cx : & LateContext < ' tcx > , local : & ' tcx Local < ' _ > ) {
610+ let local_span = cx. tcx . hir ( ) . span ( local. hir_id ) ;
610611 if_chain ! {
611- if !in_external_macro( cx. sess( ) , local . span ) ;
612- if !in_macro( local . span ) ;
612+ if !in_external_macro( cx. sess( ) , local_span ) ;
613+ if !in_macro( local_span ) ;
613614 if let Some ( ref expr) = local. init;
614615 if let ExprKind :: Match ( ref target, ref arms, MatchSource :: Normal ) = expr. kind;
615616 if arms. len( ) == 1 && arms[ 0 ] . guard. is_none( ) ;
@@ -626,7 +627,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
626627 span_lint_and_sugg(
627628 cx,
628629 INFALLIBLE_DESTRUCTURING_MATCH ,
629- local . span ,
630+ local_span ,
630631 "you seem to be trying to use `match` to destructure a single infallible pattern. \
631632 Consider using `let`",
632633 "try this" ,
@@ -1245,7 +1246,7 @@ fn check_match_single_binding<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[A
12451246 // a macro. See PR #6435
12461247 if_chain ! {
12471248 if let Some ( match_snippet) = snippet_opt( cx, expr. span) ;
1248- if let Some ( arm_snippet) = snippet_opt( cx, arms[ 0 ] . span ) ;
1249+ if let Some ( arm_snippet) = snippet_opt( cx, cx . tcx . hir ( ) . span ( arms[ 0 ] . hir_id ) ) ;
12491250 if let Some ( ex_snippet) = snippet_opt( cx, ex. span) ;
12501251 let rest_snippet = match_snippet. replace( & arm_snippet, "" ) . replace( & ex_snippet, "" ) ;
12511252 if rest_snippet. contains( "=>" ) ;
@@ -1288,7 +1289,7 @@ fn check_match_single_binding<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[A
12881289 // If this match is in a local (`let`) stmt
12891290 let ( target_span, sugg) = if let Some ( parent_let_node) = opt_parent_let ( cx, ex) {
12901291 (
1291- parent_let_node . span ,
1292+ cx . tcx . hir ( ) . span ( parent_let_node . hir_id ) ,
12921293 format ! (
12931294 "let {} = {};\n {}let {} = {};" ,
12941295 snippet_with_applicability( cx, bind_names, ".." , & mut applicability) ,
0 commit comments