]> git.lizzy.rs Git - rust.git/commitdiff
RustFmt file and tests
authorZaki Manian <zaki@manian.org>
Sun, 3 Sep 2017 18:19:59 +0000 (11:19 -0700)
committerZaki Manian <zaki@manian.org>
Sun, 3 Sep 2017 18:19:59 +0000 (11:19 -0700)
clippy_lints/src/is_unit_expr.rs
tests/ui/is_unit_expr.rs

index c9bba0c532dd89052360b0b1d28f0e5eaff4e4b1..c3860d2b92ab13809fd9bc148dd03ab4d09c484e 100644 (file)
@@ -39,20 +39,41 @@ impl EarlyLintPass for UnitExpr {
     fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) {
         if let ExprKind::Assign(ref _left, ref right) = expr.node {
             if let Some(span) = is_unit_expr(right) {
-                span_note_and_lint(cx, UNIT_EXPR, expr.span,"This expression assigns the Unit type ()",span,"Consider removing the trailing semicolon");
+                span_note_and_lint(
+                    cx,
+                    UNIT_EXPR,
+                    expr.span,
+                    "This expression assigns the Unit type ()",
+                    span,
+                    "Consider removing the trailing semicolon",
+                );
             }
         }
         if let ExprKind::MethodCall(ref _left, ref args) = expr.node {
             for ref arg in args {
                 if let Some(span) = is_unit_expr(arg) {
-                span_note_and_lint(cx, UNIT_EXPR, expr.span,"This expression assigns the Unit type ()",span,"Consider removing the trailing semicolon");
+                    span_note_and_lint(
+                        cx,
+                        UNIT_EXPR,
+                        expr.span,
+                        "This expression assigns the Unit type ()",
+                        span,
+                        "Consider removing the trailing semicolon",
+                    );
                 }
             }
         }
         if let ExprKind::Call(_, ref args) = expr.node {
             for ref arg in args {
                 if let Some(span) = is_unit_expr(arg) {
-                span_note_and_lint(cx, UNIT_EXPR, expr.span,"This expression assigns the Unit type ()",span,"Consider removing the trailing semicolon");
+                    span_note_and_lint(
+                        cx,
+                        UNIT_EXPR,
+                        expr.span,
+                        "This expression assigns the Unit type ()",
+                        span,
+                        "Consider removing the trailing semicolon",
+                    );
                 }
             }
         }
@@ -65,7 +86,14 @@ fn check_stmt(&mut self, cx: &EarlyContext, stmt: &Stmt) {
             }
             if let Some(ref expr) = local.init {
                 if let Some(span) = is_unit_expr(expr) {
-                span_note_and_lint(cx, UNIT_EXPR, expr.span,"This expression assigns the Unit type ()",span,"Consider removing the trailing semicolon");
+                    span_note_and_lint(
+                        cx,
+                        UNIT_EXPR,
+                        expr.span,
+                        "This expression assigns the Unit type ()",
+                        span,
+                        "Consider removing the trailing semicolon",
+                    );
                 }
             }
         }
@@ -84,7 +112,7 @@ fn is_unit_expr(expr: &Expr) -> Option<Span> {
                 let check_else = is_unit_expr(else_.deref());
                 if let Some(ref expr_else) = check_else {
                     return Some(expr_else.clone());
-                } 
+                }
             }
             if check_then {
                 return Some(expr.span.clone());
@@ -106,17 +134,14 @@ fn is_unit_expr(expr: &Expr) -> Option<Span> {
 
 fn check_last_stmt_in_block(block: &Block) -> bool {
     let ref final_stmt = &block.stmts[block.stmts.len() - 1];
-    
-    match final_stmt.node{
+
+    match final_stmt.node {
         StmtKind::Expr(_) => return false,
-        StmtKind::Semi(ref expr)=>{
-               match expr.node{
-                ExprKind::Break(_,_) => return false,
-                ExprKind::Ret(_) => return false,
-                _ => return true,
-            }         
+        StmtKind::Semi(ref expr) => match expr.node {
+            ExprKind::Break(_, _) => return false,
+            ExprKind::Ret(_) => return false,
+            _ => return true,
         },
         _ => return true,
     }
-
 }
index 60b07f45c6a8a6254bcb8bd3979fcf6cd3322943..63f3fcfa28c37c0c580180a4abdbb40697f2fa0e 100644 (file)
@@ -1,6 +1,5 @@
 #![feature(plugin)]
 #![plugin(clippy)]
-
 #![warn(unit_expr)]
 #[allow(unused_variables)]
 
@@ -9,5 +8,4 @@ fn main() {
         "foo";
         "baz";
     };
-
 }