@@ -60,7 +60,8 @@ impl LateLintPass for EvalOrderDependence {
6060 fn check_expr ( & mut self , cx : & LateContext , expr : & Expr ) {
6161 // Find a write to a local variable.
6262 match expr. node {
63- ExprAssign ( ref lhs, _) | ExprAssignOp ( _, ref lhs, _) => {
63+ ExprAssign ( ref lhs, _) |
64+ ExprAssignOp ( _, ref lhs, _) => {
6465 if let ExprPath ( None , ref path) = lhs. node {
6566 if path. segments . len ( ) == 1 {
6667 let var = cx. tcx . expect_def ( lhs. id ) . def_id ( ) ;
@@ -74,19 +75,20 @@ impl LateLintPass for EvalOrderDependence {
7475 }
7576 }
7677 }
77- _ => { }
78+ _ => ( ) ,
7879 }
7980 }
8081 fn check_stmt ( & mut self , cx : & LateContext , stmt : & Stmt ) {
8182 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) ,
8385 StmtDecl ( ref d, _) => {
8486 if let DeclLocal ( ref local) = d. node {
8587 if let Local { init : Some ( ref e) , .. } = * * local {
8688 DivergenceVisitor ( cx) . visit_expr ( e) ;
8789 }
8890 }
89- } ,
91+ }
9092 }
9193 }
9294}
@@ -96,7 +98,7 @@ struct DivergenceVisitor<'a, 'tcx: 'a>(&'a LateContext<'a, 'tcx>);
9698impl < ' a , ' tcx > DivergenceVisitor < ' a , ' tcx > {
9799 fn maybe_walk_expr ( & mut self , e : & Expr ) {
98100 match e. node {
99- ExprClosure ( ..) => { } ,
101+ ExprClosure ( ..) => ( ) ,
100102 ExprMatch ( ref e, ref arms, _) => {
101103 self . visit_expr ( e) ;
102104 for arm in arms {
@@ -111,12 +113,7 @@ impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
111113 }
112114 }
113115 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" ) ;
120117 }
121118}
122119
@@ -126,13 +123,17 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DivergenceVisitor<'a, 'tcx> {
126123 ExprAgain ( _) |
127124 ExprBreak ( _) |
128125 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+ }
136137 ExprMethodCall ( ..) => {
137138 let method_call = ty:: MethodCall :: expr ( e. id ) ;
138139 let borrowed_table = self . 0 . tcx . tables . borrow ( ) ;
@@ -141,10 +142,10 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DivergenceVisitor<'a, 'tcx> {
141142 if let ty:: TyNever = self . 0 . tcx . erase_late_bound_regions ( & result_ty) . sty {
142143 self . report_diverging_sub_expr ( e) ;
143144 }
144- } ,
145+ }
145146 _ => {
146147 // do not lint expressions referencing objects of type `!`, as that required a diverging expression to begin with
147- } ,
148+ }
148149 }
149150 self . maybe_walk_expr ( e) ;
150151 }
@@ -187,12 +188,12 @@ fn check_for_unsequenced_reads(vis: &mut ReadVisitor) {
187188 map:: Node :: NodeItem ( _) => {
188189 // We reached the top of the function, stop.
189190 break ;
190- } ,
191- _ => { StopEarly :: KeepGoing }
191+ }
192+ _ => StopEarly :: KeepGoing ,
192193 } ;
193194 match stop_early {
194195 StopEarly :: Stop => break ,
195- StopEarly :: KeepGoing => { } ,
196+ StopEarly :: KeepGoing => ( ) ,
196197 }
197198
198199 cur_id = parent_id;
@@ -207,7 +208,7 @@ enum StopEarly {
207208 Stop ,
208209}
209210
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 {
211212 if expr. id == vis. last_expr . id {
212213 return StopEarly :: KeepGoing ;
213214 }
@@ -248,7 +249,7 @@ fn check_expr<'v, 't>(vis: & mut ReadVisitor<'v, 't>, expr: &'v Expr) -> StopEar
248249 }
249250 // All other expressions either have only one child or strictly
250251 // sequence the evaluation order of their sub-expressions.
251- _ => { }
252+ _ => ( ) ,
252253 }
253254
254255 vis. last_expr = expr;
@@ -327,7 +328,7 @@ impl<'v, 't> Visitor<'v> for ReadVisitor<'v, 't> {
327328 ExprAddrOf ( _, _) => {
328329 return ;
329330 }
330- _ => { }
331+ _ => ( )
331332 }
332333
333334 walk_expr ( self , expr) ;
0 commit comments