@@ -486,8 +486,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
486486 // check for never_loop
487487 match expr. node {
488488 ExprKind :: While ( _, ref block, _) | ExprKind :: Loop ( ref block, _, _) => {
489- let node_id = cx. tcx . hir ( ) . hir_to_node_id ( expr. hir_id ) ;
490- match never_loop_block ( block, node_id) {
489+ match never_loop_block ( block, expr. hir_id ) {
491490 NeverLoopResult :: AlwaysBreak => {
492491 span_lint ( cx, NEVER_LOOP , expr. span , "this loop never actually loops" )
493492 } ,
@@ -664,7 +663,7 @@ fn combine_branches(b1: NeverLoopResult, b2: NeverLoopResult) -> NeverLoopResult
664663 }
665664}
666665
667- fn never_loop_block ( block : & Block , main_loop_id : NodeId ) -> NeverLoopResult {
666+ fn never_loop_block ( block : & Block , main_loop_id : HirId ) -> NeverLoopResult {
668667 let stmts = block. stmts . iter ( ) . map ( stmt_to_expr) ;
669668 let expr = once ( block. expr . as_ref ( ) . map ( |p| & * * p) ) ;
670669 let mut iter = stmts. chain ( expr) . filter_map ( |e| e) ;
@@ -679,7 +678,7 @@ fn stmt_to_expr(stmt: &Stmt) -> Option<&Expr> {
679678 }
680679}
681680
682- fn never_loop_expr ( expr : & Expr , main_loop_id : NodeId ) -> NeverLoopResult {
681+ fn never_loop_expr ( expr : & Expr , main_loop_id : HirId ) -> NeverLoopResult {
683682 match expr. node {
684683 ExprKind :: Box ( ref e)
685684 | ExprKind :: Unary ( _, ref e)
@@ -753,17 +752,17 @@ fn never_loop_expr(expr: &Expr, main_loop_id: NodeId) -> NeverLoopResult {
753752 }
754753}
755754
756- fn never_loop_expr_seq < ' a , T : Iterator < Item = & ' a Expr > > ( es : & mut T , main_loop_id : NodeId ) -> NeverLoopResult {
755+ fn never_loop_expr_seq < ' a , T : Iterator < Item = & ' a Expr > > ( es : & mut T , main_loop_id : HirId ) -> NeverLoopResult {
757756 es. map ( |e| never_loop_expr ( e, main_loop_id) )
758757 . fold ( NeverLoopResult :: Otherwise , combine_seq)
759758}
760759
761- fn never_loop_expr_all < ' a , T : Iterator < Item = & ' a Expr > > ( es : & mut T , main_loop_id : NodeId ) -> NeverLoopResult {
760+ fn never_loop_expr_all < ' a , T : Iterator < Item = & ' a Expr > > ( es : & mut T , main_loop_id : HirId ) -> NeverLoopResult {
762761 es. map ( |e| never_loop_expr ( e, main_loop_id) )
763762 . fold ( NeverLoopResult :: Otherwise , combine_both)
764763}
765764
766- fn never_loop_expr_branch < ' a , T : Iterator < Item = & ' a Expr > > ( e : & mut T , main_loop_id : NodeId ) -> NeverLoopResult {
765+ fn never_loop_expr_branch < ' a , T : Iterator < Item = & ' a Expr > > ( e : & mut T , main_loop_id : HirId ) -> NeverLoopResult {
767766 e. map ( |e| never_loop_expr ( e, main_loop_id) )
768767 . fold ( NeverLoopResult :: AlwaysBreak , combine_branches)
769768}
@@ -784,14 +783,14 @@ fn check_for_loop<'a, 'tcx>(
784783 detect_manual_memcpy ( cx, pat, arg, body, expr) ;
785784}
786785
787- fn same_var < ' a , ' tcx > ( cx : & LateContext < ' a , ' tcx > , expr : & Expr , var : ast :: NodeId ) -> bool {
786+ fn same_var < ' a , ' tcx > ( cx : & LateContext < ' a , ' tcx > , expr : & Expr , var : HirId ) -> bool {
788787 if_chain ! {
789788 if let ExprKind :: Path ( ref qpath) = expr. node;
790789 if let QPath :: Resolved ( None , ref path) = * qpath;
791790 if path. segments. len( ) == 1 ;
792791 if let Def :: Local ( local_id) = cx. tables. qpath_def( qpath, expr. hir_id) ;
793792 // our variable!
794- if local_id == var;
793+ if cx . tcx . hir ( ) . node_to_hir_id ( local_id) == var;
795794 then {
796795 return true ;
797796 }
@@ -833,8 +832,8 @@ fn is_slice_like<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'_>) -> bool {
833832 is_slice || match_type ( cx, ty, & paths:: VEC ) || match_type ( cx, ty, & paths:: VEC_DEQUE )
834833}
835834
836- fn get_fixed_offset_var < ' a , ' tcx > ( cx : & LateContext < ' a , ' tcx > , expr : & Expr , var : ast :: NodeId ) -> Option < FixedOffsetVar > {
837- fn extract_offset < ' a , ' tcx > ( cx : & LateContext < ' a , ' tcx > , e : & Expr , var : ast :: NodeId ) -> Option < String > {
835+ fn get_fixed_offset_var < ' a , ' tcx > ( cx : & LateContext < ' a , ' tcx > , expr : & Expr , var : HirId ) -> Option < FixedOffsetVar > {
836+ fn extract_offset < ' a , ' tcx > ( cx : & LateContext < ' a , ' tcx > , e : & Expr , var : HirId ) -> Option < String > {
838837 match e. node {
839838 ExprKind :: Lit ( ref l) => match l. node {
840839 ast:: LitKind :: Int ( x, _ty) => Some ( x. to_string ( ) ) ,
@@ -889,7 +888,7 @@ fn get_fixed_offset_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var:
889888fn fetch_cloned_fixed_offset_var < ' a , ' tcx > (
890889 cx : & LateContext < ' a , ' tcx > ,
891890 expr : & Expr ,
892- var : ast :: NodeId ,
891+ var : HirId ,
893892) -> Option < FixedOffsetVar > {
894893 if_chain ! {
895894 if let ExprKind :: MethodCall ( ref method, _, ref args) = expr. node;
@@ -907,12 +906,12 @@ fn fetch_cloned_fixed_offset_var<'a, 'tcx>(
907906fn get_indexed_assignments < ' a , ' tcx > (
908907 cx : & LateContext < ' a , ' tcx > ,
909908 body : & Expr ,
910- var : ast :: NodeId ,
909+ var : HirId ,
911910) -> Vec < ( FixedOffsetVar , FixedOffsetVar ) > {
912911 fn get_assignment < ' a , ' tcx > (
913912 cx : & LateContext < ' a , ' tcx > ,
914913 e : & Expr ,
915- var : ast :: NodeId ,
914+ var : HirId ,
916915 ) -> Option < ( FixedOffsetVar , FixedOffsetVar ) > {
917916 if let ExprKind :: Assign ( ref lhs, ref rhs) = e. node {
918917 match (
@@ -970,7 +969,7 @@ fn detect_manual_memcpy<'a, 'tcx>(
970969 } ) = higher:: range ( cx, arg)
971970 {
972971 // the var must be a single name
973- if let PatKind :: Binding ( _, canonical_id, _, _, _ ) = pat. node {
972+ if let PatKind :: Binding ( _, canonical_id, _, _) = pat. node {
974973 let print_sum = |arg1 : & Offset , arg2 : & Offset | -> String {
975974 match ( & arg1. value [ ..] , arg1. negate , & arg2. value [ ..] , arg2. negate ) {
976975 ( "0" , _, "0" , _) => "" . into ( ) ,
@@ -1087,7 +1086,7 @@ fn check_for_loop_range<'a, 'tcx>(
10871086 } ) = higher:: range ( cx, arg)
10881087 {
10891088 // the var must be a single name
1090- if let PatKind :: Binding ( _, canonical_id, _ , ident, _) = pat. node {
1089+ if let PatKind :: Binding ( _, canonical_id, ident, _) = pat. node {
10911090 let mut visitor = VarVisitor {
10921091 cx,
10931092 var : canonical_id,
@@ -1711,7 +1710,7 @@ impl<'tcx> Visitor<'tcx> for UsedVisitor {
17111710
17121711struct LocalUsedVisitor < ' a , ' tcx : ' a > {
17131712 cx : & ' a LateContext < ' a , ' tcx > ,
1714- local : ast :: NodeId ,
1713+ local : HirId ,
17151714 used : bool ,
17161715}
17171716
@@ -1733,7 +1732,7 @@ struct VarVisitor<'a, 'tcx: 'a> {
17331732 /// context reference
17341733 cx : & ' a LateContext < ' a , ' tcx > ,
17351734 /// var name to look for as index
1736- var : ast :: NodeId ,
1735+ var : HirId ,
17371736 /// indexed variables that are used mutably
17381737 indexed_mut : FxHashSet < Name > ,
17391738 /// indirectly indexed variables (`v[(i + 4) % N]`), the extend is `None` for global
@@ -1841,15 +1840,15 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
18411840 then {
18421841 match self . cx. tables. qpath_def( qpath, expr. hir_id) {
18431842 Def :: Upvar ( local_id, ..) => {
1844- if local_id == self . var {
1843+ if self . cx . tcx . hir ( ) . node_to_hir_id ( local_id) == self . var {
18451844 // we are not indexing anything, record that
18461845 self . nonindex = true ;
18471846 }
18481847 }
18491848 Def :: Local ( local_id) =>
18501849 {
18511850
1852- if local_id == self . var {
1851+ if self . cx . tcx . hir ( ) . node_to_hir_id ( local_id) == self . var {
18531852 self . nonindex = true ;
18541853 } else {
18551854 // not the correct variable, but still a variable
0 commit comments