Fix false positive with a = a
This commit is contained in:
parent
e65ad6f5d0
commit
6631480a7b
@ -190,6 +190,7 @@ fn check_suspicious_swap(cx: &LateContext<'_>, block: &Block<'_>) {
|
||||
&& first.span.eq_ctxt(second.span)
|
||||
&& is_same(cx, lhs0, rhs1)
|
||||
&& is_same(cx, lhs1, rhs0)
|
||||
&& !is_same(cx, lhs1, rhs1) // Ignore a = b; a = a (#10421)
|
||||
&& let Some(lhs_sugg) = match &lhs0 {
|
||||
ExprOrIdent::Expr(expr) => Sugg::hir_opt(cx, expr),
|
||||
ExprOrIdent::Ident(ident) => Some(Sugg::NonParen(ident.as_str().into())),
|
||||
|
@ -186,3 +186,11 @@ const fn issue_9864(mut u: u32) -> u32 {
|
||||
v = temp;
|
||||
u + v
|
||||
}
|
||||
|
||||
#[allow(clippy::let_and_return)]
|
||||
const fn issue_10421(x: u32) -> u32 {
|
||||
let a = x;
|
||||
let a = a;
|
||||
let a = a;
|
||||
a
|
||||
}
|
||||
|
@ -215,3 +215,11 @@ const fn issue_9864(mut u: u32) -> u32 {
|
||||
v = temp;
|
||||
u + v
|
||||
}
|
||||
|
||||
#[allow(clippy::let_and_return)]
|
||||
const fn issue_10421(x: u32) -> u32 {
|
||||
let a = x;
|
||||
let a = a;
|
||||
let a = a;
|
||||
a
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user