@@ -3,7 +3,7 @@ use if_chain::if_chain;
3
3
use itertools:: Itertools ;
4
4
use rustc:: hir:: def:: Def ;
5
5
use 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 } ;
7
7
use rustc:: hir:: * ;
8
8
use rustc:: lint:: { in_external_macro, LateContext , LateLintPass , LintArray , LintContext , LintPass } ;
9
9
use rustc:: middle:: region;
@@ -597,7 +597,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
597
597
}
598
598
599
599
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 {
601
601
if let ExprKind :: MethodCall ( ref method, _, ref args) = expr. node {
602
602
if args. len ( ) == 1 && method. ident . name == "collect" && match_trait_method ( cx, expr, & paths:: ITERATOR ) {
603
603
span_lint (
@@ -668,13 +668,7 @@ fn never_loop_block(block: &Block, main_loop_id: NodeId) -> NeverLoopResult {
668
668
fn stmt_to_expr ( stmt : & Stmt ) -> Option < & Expr > {
669
669
match stmt. node {
670
670
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) ,
678
672
_ => None ,
679
673
}
680
674
}
@@ -942,8 +936,8 @@ fn get_indexed_assignments<'a, 'tcx>(
942
936
stmts
943
937
. iter ( )
944
938
. 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) ) ,
947
941
} )
948
942
. chain ( expr. as_ref ( ) . into_iter ( ) . map ( |e| Some ( get_assignment ( cx, & * e, var) ) ) )
949
943
. filter_map ( |op| op)
@@ -1976,13 +1970,9 @@ fn extract_expr_from_first_stmt(block: &Block) -> Option<&Expr> {
1976
1970
if block. stmts . is_empty ( ) {
1977
1971
return None ;
1978
1972
}
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)
1986
1976
} else {
1987
1977
None
1988
1978
}
@@ -1996,8 +1986,8 @@ fn extract_first_expr(block: &Block) -> Option<&Expr> {
1996
1986
match block. expr {
1997
1987
Some ( ref expr) if block. stmts . is_empty ( ) => Some ( expr) ,
1998
1988
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 ,
2001
1991
} ,
2002
1992
_ => None ,
2003
1993
}
@@ -2095,9 +2085,9 @@ struct InitializeVisitor<'a, 'tcx: 'a> {
2095
2085
}
2096
2086
2097
2087
impl < ' 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 ) {
2099
2089
// Look for declarations of the variable
2100
- if let DeclKind :: Local ( ref local) = decl . node {
2090
+ if let StmtKind :: Local ( ref local) = stmt . node {
2101
2091
if local. pat . id == self . var_id {
2102
2092
if let PatKind :: Binding ( _, _, ident, _) = local. pat . node {
2103
2093
self . name = Some ( ident. name ) ;
@@ -2114,7 +2104,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
2114
2104
}
2115
2105
}
2116
2106
}
2117
- walk_decl ( self , decl ) ;
2107
+ walk_stmt ( self , stmt ) ;
2118
2108
}
2119
2109
2120
2110
fn visit_expr ( & mut self , expr : & ' tcx Expr ) {
@@ -2261,7 +2251,7 @@ struct LoopNestVisitor {
2261
2251
2262
2252
impl < ' tcx > Visitor < ' tcx > for LoopNestVisitor {
2263
2253
fn visit_stmt ( & mut self , stmt : & ' tcx Stmt ) {
2264
- if stmt. node . id ( ) == self . id {
2254
+ if stmt. id == self . id {
2265
2255
self . nesting = LookFurther ;
2266
2256
} else if self . nesting == Unknown {
2267
2257
walk_stmt ( self , stmt) ;
0 commit comments