mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
Cleanup, use matches!
some more
This commit is contained in:
parent
7211df5a17
commit
7bc7c675f2
3 changed files with 8 additions and 27 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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(_))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue