]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/eval_order_dependence.rs
Merge branch 'macro-use' into HEAD
[rust.git] / clippy_lints / src / eval_order_dependence.rs
index ebbffc6680807ddacecd5df67e64289f422c5732..b0295d2e7d471d0f1cb70028bb572c408bfc6599 100644 (file)
@@ -2,6 +2,8 @@
 use rustc::hir::*;
 use rustc::ty;
 use rustc::lint::*;
+use rustc::{declare_lint, lint_array};
+use if_chain::if_chain;
 use syntax::ast;
 use crate::utils::{get_parent_expr, span_lint, span_note_and_lint};
 
@@ -82,8 +84,8 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
     }
     fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
         match stmt.node {
-            StmtExpr(ref e, _) | StmtSemi(ref e, _) => DivergenceVisitor { cx }.maybe_walk_expr(e),
-            StmtDecl(ref d, _) => if let DeclLocal(ref local) = d.node {
+            StmtKind::Expr(ref e, _) | StmtKind::Semi(ref e, _) => DivergenceVisitor { cx }.maybe_walk_expr(e),
+            StmtKind::Decl(ref d, _) => if let DeclKind::Local(ref local) = d.node {
                 if let Local {
                     init: Some(ref e), ..
                 } = **local
@@ -229,7 +231,7 @@ fn check_expr<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr) -> St
             walk_expr(vis, expr);
         },
         ExprKind::Binary(op, _, _) | ExprKind::AssignOp(op, _, _) => {
-            if op.node == BiAnd || op.node == BiOr {
+            if op.node == BinOpKind::And || op.node == BinOpKind::Or {
                 // x && y and x || y always evaluate x first, so these are
                 // strictly sequenced.
             } else {
@@ -262,12 +264,12 @@ fn check_expr<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr) -> St
 
 fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> StopEarly {
     match stmt.node {
-        StmtExpr(ref expr, _) | StmtSemi(ref expr, _) => check_expr(vis, expr),
-        StmtDecl(ref decl, _) => {
+        StmtKind::Expr(ref expr, _) | StmtKind::Semi(ref expr, _) => check_expr(vis, expr),
+        StmtKind::Decl(ref decl, _) => {
             // If the declaration is of a local variable, check its initializer
             // expression if it has one. Otherwise, keep going.
             let local = match decl.node {
-                DeclLocal(ref local) => Some(local),
+                DeclKind::Local(ref local) => Some(local),
                 _ => None,
             };
             local