Skip to content

Commit 9494f22

Browse files
committed
cargo fmt
1 parent 5c9221f commit 9494f22

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

clippy_lints/src/assign_ops.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
6868
match &expr.node {
6969
hir::ExprKind::AssignOp(op, lhs, rhs) => {
7070
if let hir::ExprKind::Binary(binop, l, r) = &rhs.node {
71-
if op.node != binop.node { return; }
71+
if op.node != binop.node {
72+
return;
73+
}
7274
// lhs op= l op r
7375
if SpanlessEq::new(cx).ignore_fn().eq_expr(lhs, l) {
7476
lint_misrefactored_assign_op(cx, expr, *op, rhs, lhs, r);
@@ -196,20 +198,24 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
196198
}
197199
}
198200

199-
fn lint_misrefactored_assign_op(cx: &LateContext<'_, '_>, expr: &hir::Expr, op: hir::BinOp, rhs: &hir::Expr, assignee: &hir::Expr, rhs_other: &hir::Expr) {
201+
fn lint_misrefactored_assign_op(
202+
cx: &LateContext<'_, '_>,
203+
expr: &hir::Expr,
204+
op: hir::BinOp,
205+
rhs: &hir::Expr,
206+
assignee: &hir::Expr,
207+
rhs_other: &hir::Expr,
208+
) {
200209
span_lint_and_then(
201210
cx,
202211
MISREFACTORED_ASSIGN_OP,
203212
expr.span,
204213
"variable appears on both sides of an assignment operation",
205214
|db| {
206-
if let (Some(snip_a), Some(snip_r)) =
207-
(snippet_opt(cx, assignee.span), snippet_opt(cx, rhs_other.span))
208-
{
215+
if let (Some(snip_a), Some(snip_r)) = (snippet_opt(cx, assignee.span), snippet_opt(cx, rhs_other.span)) {
209216
let a = &sugg::Sugg::hir(cx, assignee, "..");
210217
let r = &sugg::Sugg::hir(cx, rhs, "..");
211-
let long =
212-
format!("{} = {}", snip_a, sugg::make_binop(higher::binop(op.node), a, r));
218+
let long = format!("{} = {}", snip_a, sugg::make_binop(higher::binop(op.node), a, r));
213219
db.span_suggestion(
214220
expr.span,
215221
&format!(

0 commit comments

Comments
 (0)