about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Wright <mikerite@lavabit.com>2019-01-20 12:49:45 +0200
committerMichael Wright <mikerite@lavabit.com>2019-01-20 12:49:45 +0200
commit8747691bea639835e66c6cef0baf66063f0aae93 (patch)
tree82ac07af30cf0eec1a58bc1fea25d4b86f89e703
parentf51f0178dd5ba19c905d8b323dab2c43ded83b1e (diff)
downloadrust-8747691bea639835e66c6cef0baf66063f0aae93.tar.gz
rust-8747691bea639835e66c6cef0baf66063f0aae93.zip
Run rustfmt
-rw-r--r--clippy_lints/src/escape.rs18
-rw-r--r--clippy_lints/src/eval_order_dependence.rs13
-rw-r--r--clippy_lints/src/loops.rs10
-rw-r--r--clippy_lints/src/methods/mod.rs8
-rw-r--r--clippy_lints/src/shadow.rs32
-rw-r--r--clippy_lints/src/utils/hir_utils.rs11
-rw-r--r--clippy_lints/src/utils/inspector.rs2
7 files changed, 48 insertions, 46 deletions
diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs
index 79af6305f44..a7b47fd1e54 100644
--- a/clippy_lints/src/escape.rs
+++ b/clippy_lints/src/escape.rs
@@ -121,20 +121,20 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
             let id = map.hir_to_node_id(cmt.hir_id);
             if let Some(Node::Stmt(st)) = map.find(map.get_parent_node(id)) {
                 if let StmtKind::Local(ref loc) = st.node {
-                        if let Some(ref ex) = loc.init {
-                            if let ExprKind::Box(..) = ex.node {
-                                if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
-                                    // let x = box (...)
-                                    self.set.insert(consume_pat.id);
-                                }
-                                // TODO Box::new
-                                // TODO vec![]
-                                // TODO "foo".to_owned() and friends
+                    if let Some(ref ex) = loc.init {
+                        if let ExprKind::Box(..) = ex.node {
+                            if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
+                                // let x = box (...)
+                                self.set.insert(consume_pat.id);
                             }
+                            // TODO Box::new
+                            // TODO vec![]
+                            // TODO "foo".to_owned() and friends
                         }
                     }
                 }
             }
+        }
         if let Categorization::Local(lid) = cmt.cat {
             if self.set.contains(&lid) {
                 // let y = x where x is known
diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs
index 74fe4a6589b..2b4b0d40239 100644
--- a/clippy_lints/src/eval_order_dependence.rs
+++ b/clippy_lints/src/eval_order_dependence.rs
@@ -90,9 +90,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence {
     fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
         match stmt.node {
             StmtKind::Local(ref local) => {
-                    if let Local { init: Some(ref e), .. } = **local {
-                        DivergenceVisitor { cx }.visit_expr(e);
-                    }
+                if let Local { init: Some(ref e), .. } = **local {
+                    DivergenceVisitor { cx }.visit_expr(e);
+                }
             },
             StmtKind::Expr(ref e) | StmtKind::Semi(ref e) => DivergenceVisitor { cx }.maybe_walk_expr(e),
             StmtKind::Item(..) => {},
@@ -271,9 +271,10 @@ fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> St
         StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => check_expr(vis, expr),
         // If the declaration is of a local variable, check its initializer
         // expression if it has one. Otherwise, keep going.
-        StmtKind::Local(ref local) => {
-            local.init.as_ref().map_or(StopEarly::KeepGoing, |expr| check_expr(vis, expr))
-        },
+        StmtKind::Local(ref local) => local
+            .init
+            .as_ref()
+            .map_or(StopEarly::KeepGoing, |expr| check_expr(vis, expr)),
         _ => StopEarly::KeepGoing,
     }
 }
diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs
index 7d8b7d363b1..70ff86087ea 100644
--- a/clippy_lints/src/loops.rs
+++ b/clippy_lints/src/loops.rs
@@ -1971,11 +1971,11 @@ fn extract_expr_from_first_stmt(block: &Block) -> Option<&Expr> {
         return None;
     }
     if let StmtKind::Local(ref local) = block.stmts[0].node {
-            if let Some(ref expr) = local.init {
-                Some(expr)
-            } else {
-                None
-            }
+        if let Some(ref expr) = local.init {
+            Some(expr)
+        } else {
+            None
+        }
     } else {
         None
     }
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs
index 5883128d72c..6c1befe6e53 100644
--- a/clippy_lints/src/methods/mod.rs
+++ b/clippy_lints/src/methods/mod.rs
@@ -1337,10 +1337,10 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
                     },
                     hir::Node::Stmt(stmt) => {
                         if let hir::StmtKind::Local(ref loc) = stmt.node {
-                                if let hir::PatKind::Ref(..) = loc.pat.node {
-                                    // let ref y = *x borrows x, let ref y = x.clone() does not
-                                    return;
-                                }
+                            if let hir::PatKind::Ref(..) = loc.pat.node {
+                                // let ref y = *x borrows x, let ref y = x.clone() does not
+                                return;
+                            }
                         }
                     },
                     _ => {},
diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs
index 153324094ec..c99b00bb98f 100644
--- a/clippy_lints/src/shadow.rs
+++ b/clippy_lints/src/shadow.rs
@@ -133,22 +133,22 @@ fn check_local<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, local: &'tcx Local, binding
     if higher::is_from_for_desugar(local) {
         return;
     }
-        let Local {
-            ref pat,
-            ref ty,
-            ref init,
-            span,
-            ..
-        } = *local;
-        if let Some(ref t) = *ty {
-            check_ty(cx, t, bindings)
-        }
-        if let Some(ref o) = *init {
-            check_expr(cx, o, bindings);
-            check_pat(cx, pat, Some(o), span, bindings);
-        } else {
-            check_pat(cx, pat, None, span, bindings);
-        }
+    let Local {
+        ref pat,
+        ref ty,
+        ref init,
+        span,
+        ..
+    } = *local;
+    if let Some(ref t) = *ty {
+        check_ty(cx, t, bindings)
+    }
+    if let Some(ref o) = *init {
+        check_expr(cx, o, bindings);
+        check_pat(cx, pat, Some(o), span, bindings);
+    } else {
+        check_pat(cx, pat, None, span, bindings);
+    }
 }
 
 fn is_binding(cx: &LateContext<'_, '_>, pat_id: HirId) -> bool {
diff --git a/clippy_lints/src/utils/hir_utils.rs b/clippy_lints/src/utils/hir_utils.rs
index aae4eb24964..a176830be26 100644
--- a/clippy_lints/src/utils/hir_utils.rs
+++ b/clippy_lints/src/utils/hir_utils.rs
@@ -43,13 +43,14 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
     /// Check whether two statements are the same.
     pub fn eq_stmt(&mut self, left: &Stmt, right: &Stmt) -> bool {
         match (&left.node, &right.node) {
-            (&StmtKind::Local(ref l), &StmtKind::Local(ref r)) =>
+            (&StmtKind::Local(ref l), &StmtKind::Local(ref r)) => {
                 self.eq_pat(&l.pat, &r.pat)
                     && both(&l.ty, &r.ty, |l, r| self.eq_ty(l, r))
                     && both(&l.init, &r.init, |l, r| self.eq_expr(l, r))
-            ,
-            (&StmtKind::Expr(ref l), &StmtKind::Expr(ref r))
-            | (&StmtKind::Semi(ref l), &StmtKind::Semi(ref r)) => self.eq_expr(l, r),
+            },
+            (&StmtKind::Expr(ref l), &StmtKind::Expr(ref r)) | (&StmtKind::Semi(ref l), &StmtKind::Semi(ref r)) => {
+                self.eq_expr(l, r)
+            },
             _ => false,
         }
     }
@@ -649,7 +650,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
             StmtKind::Item(..) => {
                 let c: fn(_) -> _ = StmtKind::Item;
                 c.hash(&mut self.s);
-            }
+            },
             StmtKind::Expr(ref expr) => {
                 let c: fn(_) -> _ = StmtKind::Expr;
                 c.hash(&mut self.s);
diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs
index 235b2adc62e..4116f8ffbaf 100644
--- a/clippy_lints/src/utils/inspector.rs
+++ b/clippy_lints/src/utils/inspector.rs
@@ -130,7 +130,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
                     println!("init expression:");
                     print_expr(cx, e, 0);
                 }
-            }
+            },
             hir::StmtKind::Item(_) => println!("item decl"),
             hir::StmtKind::Expr(ref e) | hir::StmtKind::Semi(ref e) => print_expr(cx, e, 0),
         }