diff --git a/clippy_lints/src/block_in_if_condition.rs b/clippy_lints/src/block_in_if_condition.rs index c56cf4dcd292..b8f1bb71ad95 100644 --- a/clippy_lints/src/block_in_if_condition.rs +++ b/clippy_lints/src/block_in_if_condition.rs @@ -47,10 +47,7 @@ impl<'v> Visitor<'v> for ExVisitor<'v> { 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 } diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index f9f557e7a9a2..c37fbba9250d 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -1023,11 +1023,7 @@ impl OutType { (&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 @@ impl OutType { 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 { diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 5f113cf47cea..53f4c9726448 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -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]) -> 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(_)) }) }) }