impl<'tcx> LateLintPass<'tcx> for EqOp {
#[allow(clippy::similar_names, clippy::too_many_lines)]
fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
- if let ExprKind::Block(ref block, _) = e.kind {
+ if let ExprKind::Block(block, _) = e.kind {
for stmt in block.stmts {
for amn in &ASSERT_MACRO_NAMES {
if_chain! {
if is_expn_of(stmt.span, amn).is_some();
- if let StmtKind::Semi(ref matchexpr) = stmt.kind;
+ if let StmtKind::Semi(matchexpr) = stmt.kind;
if let Some(macro_args) = higher::extract_assert_macro_args(matchexpr);
if macro_args.len() == 2;
let (lhs, rhs) = (macro_args[0], macro_args[1]);
}
}
}
- if let ExprKind::Binary(op, ref left, ref right) = e.kind {
+ if let ExprKind::Binary(op, left, right) = e.kind {
if e.span.from_expansion() {
return;
}
let macro_with_not_op = |expr_kind: &ExprKind<'_>| {
- if let ExprKind::Unary(_, ref expr) = *expr_kind {
+ if let ExprKind::Unary(_, expr) = *expr_kind {
in_macro(expr.span)
} else {
false
// do not suggest to dereference literals
(&ExprKind::Lit(..), _) | (_, &ExprKind::Lit(..)) => {},
// &foo == &bar
- (&ExprKind::AddrOf(BorrowKind::Ref, _, ref l), &ExprKind::AddrOf(BorrowKind::Ref, _, ref r)) => {
+ (&ExprKind::AddrOf(BorrowKind::Ref, _, l), &ExprKind::AddrOf(BorrowKind::Ref, _, r)) => {
let lty = cx.typeck_results().expr_ty(l);
let rty = cx.typeck_results().expr_ty(r);
let lcpy = is_copy(cx, lty);
vec![(left.span, lsnip), (right.span, rsnip)],
);
},
- )
+ );
} else if lcpy
&& !rcpy
&& implements_trait(cx, lty, trait_id, &[cx.typeck_results().expr_ty(right).into()])
Applicability::MaybeIncorrect, // FIXME #2597
);
},
- )
+ );
} else if !lcpy
&& rcpy
&& implements_trait(cx, cx.typeck_results().expr_ty(left), trait_id, &[rty.into()])
Applicability::MaybeIncorrect, // FIXME #2597
);
},
- )
+ );
}
},
// &foo == bar
- (&ExprKind::AddrOf(BorrowKind::Ref, _, ref l), _) => {
+ (&ExprKind::AddrOf(BorrowKind::Ref, _, l), _) => {
let lty = cx.typeck_results().expr_ty(l);
let lcpy = is_copy(cx, lty);
if (requires_ref || lcpy)
Applicability::MaybeIncorrect, // FIXME #2597
);
},
- )
+ );
}
},
// foo == &bar
- (_, &ExprKind::AddrOf(BorrowKind::Ref, _, ref r)) => {
+ (_, &ExprKind::AddrOf(BorrowKind::Ref, _, r)) => {
let rty = cx.typeck_results().expr_ty(r);
let rcpy = is_copy(cx, rty);
if (requires_ref || rcpy)
rsnip,
Applicability::MaybeIncorrect, // FIXME #2597
);
- })
+ });
}
},
_ => {},