(&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,
}
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 {
}
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.
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.
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(_))
})
})
}