@@ -60,7 +60,8 @@ impl LateLintPass for EvalOrderDependence {
60
60
fn check_expr ( & mut self , cx : & LateContext , expr : & Expr ) {
61
61
// Find a write to a local variable.
62
62
match expr. node {
63
- ExprAssign ( ref lhs, _) | ExprAssignOp ( _, ref lhs, _) => {
63
+ ExprAssign ( ref lhs, _) |
64
+ ExprAssignOp ( _, ref lhs, _) => {
64
65
if let ExprPath ( None , ref path) = lhs. node {
65
66
if path. segments . len ( ) == 1 {
66
67
let var = cx. tcx . expect_def ( lhs. id ) . def_id ( ) ;
@@ -74,19 +75,20 @@ impl LateLintPass for EvalOrderDependence {
74
75
}
75
76
}
76
77
}
77
- _ => { }
78
+ _ => ( ) ,
78
79
}
79
80
}
80
81
fn check_stmt ( & mut self , cx : & LateContext , stmt : & Stmt ) {
81
82
match stmt. node {
82
- StmtExpr ( ref e, _) | StmtSemi ( ref e, _) => DivergenceVisitor ( cx) . maybe_walk_expr ( e) ,
83
+ StmtExpr ( ref e, _) |
84
+ StmtSemi ( ref e, _) => DivergenceVisitor ( cx) . maybe_walk_expr ( e) ,
83
85
StmtDecl ( ref d, _) => {
84
86
if let DeclLocal ( ref local) = d. node {
85
87
if let Local { init : Some ( ref e) , .. } = * * local {
86
88
DivergenceVisitor ( cx) . visit_expr ( e) ;
87
89
}
88
90
}
89
- } ,
91
+ }
90
92
}
91
93
}
92
94
}
@@ -96,7 +98,7 @@ struct DivergenceVisitor<'a, 'tcx: 'a>(&'a LateContext<'a, 'tcx>);
96
98
impl < ' a , ' tcx > DivergenceVisitor < ' a , ' tcx > {
97
99
fn maybe_walk_expr ( & mut self , e : & Expr ) {
98
100
match e. node {
99
- ExprClosure ( ..) => { } ,
101
+ ExprClosure ( ..) => ( ) ,
100
102
ExprMatch ( ref e, ref arms, _) => {
101
103
self . visit_expr ( e) ;
102
104
for arm in arms {
@@ -111,12 +113,7 @@ impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
111
113
}
112
114
}
113
115
fn report_diverging_sub_expr ( & mut self , e : & Expr ) {
114
- span_lint (
115
- self . 0 ,
116
- DIVERGING_SUB_EXPRESSION ,
117
- e. span ,
118
- "sub-expression diverges" ,
119
- ) ;
116
+ span_lint ( self . 0 , DIVERGING_SUB_EXPRESSION , e. span , "sub-expression diverges" ) ;
120
117
}
121
118
}
122
119
@@ -126,13 +123,17 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DivergenceVisitor<'a, 'tcx> {
126
123
ExprAgain ( _) |
127
124
ExprBreak ( _) |
128
125
ExprRet ( _) => self . report_diverging_sub_expr ( e) ,
129
- ExprCall ( ref func, _) => match self . 0 . tcx . expr_ty ( func) . sty {
130
- ty:: TyFnDef ( _, _, fn_ty) |
131
- ty:: TyFnPtr ( fn_ty) => if let ty:: TyNever = self . 0 . tcx . erase_late_bound_regions ( & fn_ty. sig ) . output . sty {
132
- self . report_diverging_sub_expr ( e) ;
133
- } ,
134
- _ => { } ,
135
- } ,
126
+ ExprCall ( ref func, _) => {
127
+ match self . 0 . tcx . expr_ty ( func) . sty {
128
+ ty:: TyFnDef ( _, _, fn_ty) |
129
+ ty:: TyFnPtr ( fn_ty) => {
130
+ if let ty:: TyNever = self . 0 . tcx . erase_late_bound_regions ( & fn_ty. sig ) . output . sty {
131
+ self . report_diverging_sub_expr ( e) ;
132
+ }
133
+ }
134
+ _ => ( ) ,
135
+ }
136
+ }
136
137
ExprMethodCall ( ..) => {
137
138
let method_call = ty:: MethodCall :: expr ( e. id ) ;
138
139
let borrowed_table = self . 0 . tcx . tables . borrow ( ) ;
@@ -141,10 +142,10 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DivergenceVisitor<'a, 'tcx> {
141
142
if let ty:: TyNever = self . 0 . tcx . erase_late_bound_regions ( & result_ty) . sty {
142
143
self . report_diverging_sub_expr ( e) ;
143
144
}
144
- } ,
145
+ }
145
146
_ => {
146
147
// do not lint expressions referencing objects of type `!`, as that required a diverging expression to begin with
147
- } ,
148
+ }
148
149
}
149
150
self . maybe_walk_expr ( e) ;
150
151
}
@@ -187,12 +188,12 @@ fn check_for_unsequenced_reads(vis: &mut ReadVisitor) {
187
188
map:: Node :: NodeItem ( _) => {
188
189
// We reached the top of the function, stop.
189
190
break ;
190
- } ,
191
- _ => { StopEarly :: KeepGoing }
191
+ }
192
+ _ => StopEarly :: KeepGoing ,
192
193
} ;
193
194
match stop_early {
194
195
StopEarly :: Stop => break ,
195
- StopEarly :: KeepGoing => { } ,
196
+ StopEarly :: KeepGoing => ( ) ,
196
197
}
197
198
198
199
cur_id = parent_id;
@@ -207,7 +208,7 @@ enum StopEarly {
207
208
Stop ,
208
209
}
209
210
210
- fn check_expr < ' v , ' t > ( vis : & mut ReadVisitor < ' v , ' t > , expr : & ' v Expr ) -> StopEarly {
211
+ fn check_expr < ' v , ' t > ( vis : & mut ReadVisitor < ' v , ' t > , expr : & ' v Expr ) -> StopEarly {
211
212
if expr. id == vis. last_expr . id {
212
213
return StopEarly :: KeepGoing ;
213
214
}
@@ -248,7 +249,7 @@ fn check_expr<'v, 't>(vis: & mut ReadVisitor<'v, 't>, expr: &'v Expr) -> StopEar
248
249
}
249
250
// All other expressions either have only one child or strictly
250
251
// sequence the evaluation order of their sub-expressions.
251
- _ => { }
252
+ _ => ( ) ,
252
253
}
253
254
254
255
vis. last_expr = expr;
@@ -327,7 +328,7 @@ impl<'v, 't> Visitor<'v> for ReadVisitor<'v, 't> {
327
328
ExprAddrOf ( _, _) => {
328
329
return ;
329
330
}
330
- _ => { }
331
+ _ => ( )
331
332
}
332
333
333
334
walk_expr ( self , expr) ;
0 commit comments