@@ -68,7 +68,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
68
68
match & expr. node {
69
69
hir:: ExprKind :: AssignOp ( op, lhs, rhs) => {
70
70
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
+ }
72
74
// lhs op= l op r
73
75
if SpanlessEq :: new ( cx) . ignore_fn ( ) . eq_expr ( lhs, l) {
74
76
lint_misrefactored_assign_op ( cx, expr, * op, rhs, lhs, r) ;
@@ -196,20 +198,24 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
196
198
}
197
199
}
198
200
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
+ ) {
200
209
span_lint_and_then (
201
210
cx,
202
211
MISREFACTORED_ASSIGN_OP ,
203
212
expr. span ,
204
213
"variable appears on both sides of an assignment operation" ,
205
214
|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 ) ) {
209
216
let a = & sugg:: Sugg :: hir ( cx, assignee, ".." ) ;
210
217
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) ) ;
213
219
db. span_suggestion (
214
220
expr. span ,
215
221
& format ! (
0 commit comments