]> git.lizzy.rs Git - rust.git/commitdiff
Cleanup, use `matches!` some more
authormcarton <cartonmartin+git@gmail.com>
Sun, 5 Jun 2016 18:46:42 +0000 (20:46 +0200)
committermcarton <cartonmartin+git@gmail.com>
Sun, 5 Jun 2016 18:46:42 +0000 (20:46 +0200)
clippy_lints/src/block_in_if_condition.rs
clippy_lints/src/methods.rs
clippy_lints/src/misc.rs

index c56cf4dcd29237a623a853cbb9c819558b8f4f00..b8f1bb71ad95c57e61e275359ae13216d99f3390 100644 (file)
@@ -47,10 +47,7 @@ fn visit_expr(&mut self, expr: &'v Expr) {
             let complex = {
                 if block.stmts.is_empty() {
                     if let Some(ref ex) = block.expr {
-                        match ex.node {
-                            ExprBlock(_) => true,
-                            _ => false,
-                        }
+                        matches!(ex.node, ExprBlock(_))
                     } else {
                         false
                     }
index f9f557e7a9a254111b5d080523c27fe092a84eb3..c37fbba9250d4dd8e76713dfc56d5c669e00a389 100644 (file)
@@ -1023,11 +1023,7 @@ fn matches(&self, ty: &hir::FunctionRetTy) -> bool {
             (&OutType::Bool, &hir::Return(ref ty)) if is_bool(ty) => true,
             (&OutType::Any, &hir::Return(ref ty)) if ty.node != hir::TyTup(vec![].into()) => true,
             (&OutType::Ref, &hir::Return(ref ty)) => {
-                if let hir::TyRptr(_, _) = ty.node {
-                    true
-                } else {
-                    false
-                }
+                matches!(ty.node, hir::TyRptr(_, _))
             }
             _ => false,
         }
@@ -1036,11 +1032,10 @@ fn matches(&self, ty: &hir::FunctionRetTy) -> bool {
 
 fn is_bool(ty: &hir::Ty) -> bool {
     if let hir::TyPath(None, ref p) = ty.node {
-        if match_path(p, &["bool"]) {
-            return true;
-        }
+        match_path(p, &["bool"])
+    } else {
+        false
     }
-    false
 }
 
 fn is_copy<'a, 'ctx>(cx: &LateContext<'a, 'ctx>, ty: ty::Ty<'ctx>, item: &hir::Item) -> bool {
index 5f113cf47ceae79bbaec283e7c0b0f1ab361075e..53f4c972644832a11ee857ceed84ffbd0da1146f 100644 (file)
@@ -189,11 +189,7 @@ fn is_allowed(cx: &LateContext, expr: &Expr) -> bool {
 }
 
 fn is_float(cx: &LateContext, expr: &Expr) -> bool {
-    if let ty::TyFloat(_) = walk_ptrs_ty(cx.tcx.expr_ty(expr)).sty {
-        true
-    } else {
-        false
-    }
+    matches!(walk_ptrs_ty(cx.tcx.expr_ty(expr)).sty, ty::TyFloat(_))
 }
 
 /// **What it does:** This lint checks for conversions to owned values just for the sake of a comparison.
@@ -283,11 +279,7 @@ fn check_to_owned(cx: &LateContext, expr: &Expr, other: &Expr, left: bool, op: S
 
 fn is_str_arg(cx: &LateContext, args: &[P<Expr>]) -> bool {
     args.len() == 1 &&
-    if let ty::TyStr = walk_ptrs_ty(cx.tcx.expr_ty(&args[0])).sty {
-        true
-    } else {
-        false
-    }
+        matches!(walk_ptrs_ty(cx.tcx.expr_ty(&args[0])).sty, ty::TyStr)
 }
 
 /// **What it does:** This lint checks for getting the remainder of a division by one.
@@ -449,10 +441,7 @@ fn is_used(cx: &LateContext, expr: &Expr) -> bool {
 fn in_attributes_expansion(cx: &LateContext, expr: &Expr) -> bool {
     cx.sess().codemap().with_expn_info(expr.span.expn_id, |info_opt| {
         info_opt.map_or(false, |info| {
-            match info.callee.format {
-                ExpnFormat::MacroAttribute(_) => true,
-                _ => false,
-            }
+            matches!(info.callee.format, ExpnFormat::MacroAttribute(_))
         })
     })
 }