Swap if branches
This commit is contained in:
parent
d90cad24a1
commit
fe3519e0dd
@ -1333,7 +1333,9 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
|
||||
let snip;
|
||||
if let Some(snippet) = sugg::Sugg::hir_opt(cx, arg) {
|
||||
// x.clone() might have dereferenced x, possibly through Deref impls
|
||||
if cx.tables.expr_ty(arg) != ty {
|
||||
if cx.tables.expr_ty(arg) == ty {
|
||||
snip = Some(("try removing the `clone` call", format!("{}", snippet)));
|
||||
} else {
|
||||
let parent = cx.tcx.hir().get_parent_node(expr.id);
|
||||
match cx.tcx.hir().get(parent) {
|
||||
hir::Node::Expr(parent) => match parent.node {
|
||||
@ -1367,8 +1369,6 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
|
||||
.count();
|
||||
let derefs: String = iter::repeat('*').take(deref_count).collect();
|
||||
snip = Some(("try dereferencing it", format!("{}{}", derefs, snippet)));
|
||||
} else {
|
||||
snip = Some(("try removing the `clone` call", format!("{}", snippet)));
|
||||
}
|
||||
} else {
|
||||
snip = None;
|
||||
|
Loading…
Reference in New Issue
Block a user