@@ -3,7 +3,7 @@ use if_chain::if_chain;
33use itertools:: Itertools ;
44use rustc:: hir:: def:: Def ;
55use rustc:: hir:: def_id;
6- use rustc:: hir:: intravisit:: { walk_block, walk_decl , walk_expr, walk_pat, walk_stmt, NestedVisitorMap , Visitor } ;
6+ use rustc:: hir:: intravisit:: { walk_block, walk_expr, walk_pat, walk_stmt, NestedVisitorMap , Visitor } ;
77use rustc:: hir:: * ;
88use rustc:: lint:: { in_external_macro, LateContext , LateLintPass , LintArray , LintContext , LintPass } ;
99use rustc:: middle:: region;
@@ -597,7 +597,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
597597 }
598598
599599 fn check_stmt ( & mut self , cx : & LateContext < ' a , ' tcx > , stmt : & ' tcx Stmt ) {
600- if let StmtKind :: Semi ( ref expr, _ ) = stmt. node {
600+ if let StmtKind :: Semi ( ref expr) = stmt. node {
601601 if let ExprKind :: MethodCall ( ref method, _, ref args) = expr. node {
602602 if args. len ( ) == 1 && method. ident . name == "collect" && match_trait_method ( cx, expr, & paths:: ITERATOR ) {
603603 span_lint (
@@ -668,13 +668,7 @@ fn never_loop_block(block: &Block, main_loop_id: NodeId) -> NeverLoopResult {
668668fn stmt_to_expr ( stmt : & Stmt ) -> Option < & Expr > {
669669 match stmt. node {
670670 StmtKind :: Semi ( ref e, ..) | StmtKind :: Expr ( ref e, ..) => Some ( e) ,
671- StmtKind :: Decl ( ref d, ..) => decl_to_expr ( d) ,
672- }
673- }
674-
675- fn decl_to_expr ( decl : & Decl ) -> Option < & Expr > {
676- match decl. node {
677- DeclKind :: Local ( ref local) => local. init . as_ref ( ) . map ( |p| & * * p) ,
671+ StmtKind :: Local ( ref local) => local. init . as_ref ( ) . map ( |p| & * * p) ,
678672 _ => None ,
679673 }
680674}
@@ -942,8 +936,8 @@ fn get_indexed_assignments<'a, 'tcx>(
942936 stmts
943937 . iter ( )
944938 . map ( |stmt| match stmt. node {
945- StmtKind :: Decl ( ..) => None ,
946- StmtKind :: Expr ( ref e, _node_id ) | StmtKind :: Semi ( ref e, _node_id ) => Some ( get_assignment ( cx, e, var) ) ,
939+ StmtKind :: Local ( .. ) | StmtKind :: Item ( ..) => None ,
940+ StmtKind :: Expr ( ref e) | StmtKind :: Semi ( ref e) => Some ( get_assignment ( cx, e, var) ) ,
947941 } )
948942 . chain ( expr. as_ref ( ) . into_iter ( ) . map ( |e| Some ( get_assignment ( cx, & * e, var) ) ) )
949943 . filter_map ( |op| op)
@@ -1976,13 +1970,9 @@ fn extract_expr_from_first_stmt(block: &Block) -> Option<&Expr> {
19761970 if block. stmts . is_empty ( ) {
19771971 return None ;
19781972 }
1979- if let StmtKind :: Decl ( ref decl, _) = block. stmts [ 0 ] . node {
1980- if let DeclKind :: Local ( ref local) = decl. node {
1981- if let Some ( ref expr) = local. init {
1982- Some ( expr)
1983- } else {
1984- None
1985- }
1973+ if let StmtKind :: Local ( ref local) = block. stmts [ 0 ] . node {
1974+ if let Some ( ref expr) = local. init {
1975+ Some ( expr)
19861976 } else {
19871977 None
19881978 }
@@ -1996,8 +1986,8 @@ fn extract_first_expr(block: &Block) -> Option<&Expr> {
19961986 match block. expr {
19971987 Some ( ref expr) if block. stmts . is_empty ( ) => Some ( expr) ,
19981988 None if !block. stmts . is_empty ( ) => match block. stmts [ 0 ] . node {
1999- StmtKind :: Expr ( ref expr, _ ) | StmtKind :: Semi ( ref expr, _ ) => Some ( expr) ,
2000- StmtKind :: Decl ( ..) => None ,
1989+ StmtKind :: Expr ( ref expr) | StmtKind :: Semi ( ref expr) => Some ( expr) ,
1990+ StmtKind :: Local ( .. ) | StmtKind :: Item ( ..) => None ,
20011991 } ,
20021992 _ => None ,
20031993 }
@@ -2095,9 +2085,9 @@ struct InitializeVisitor<'a, 'tcx: 'a> {
20952085}
20962086
20972087impl < ' a , ' tcx > Visitor < ' tcx > for InitializeVisitor < ' a , ' tcx > {
2098- fn visit_decl ( & mut self , decl : & ' tcx Decl ) {
2088+ fn visit_stmt ( & mut self , stmt : & ' tcx Stmt ) {
20992089 // Look for declarations of the variable
2100- if let DeclKind :: Local ( ref local) = decl . node {
2090+ if let StmtKind :: Local ( ref local) = stmt . node {
21012091 if local. pat . id == self . var_id {
21022092 if let PatKind :: Binding ( _, _, ident, _) = local. pat . node {
21032093 self . name = Some ( ident. name ) ;
@@ -2114,7 +2104,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
21142104 }
21152105 }
21162106 }
2117- walk_decl ( self , decl ) ;
2107+ walk_stmt ( self , stmt ) ;
21182108 }
21192109
21202110 fn visit_expr ( & mut self , expr : & ' tcx Expr ) {
@@ -2261,7 +2251,7 @@ struct LoopNestVisitor {
22612251
22622252impl < ' tcx > Visitor < ' tcx > for LoopNestVisitor {
22632253 fn visit_stmt ( & mut self , stmt : & ' tcx Stmt ) {
2264- if stmt. node . id ( ) == self . id {
2254+ if stmt. id == self . id {
22652255 self . nesting = LookFurther ;
22662256 } else if self . nesting == Unknown {
22672257 walk_stmt ( self , stmt) ;
0 commit comments