]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/misrefactored_assign_op.txt
:arrow_up: rust-analyzer
[rust.git] / src / tools / clippy / src / docs / misrefactored_assign_op.txt
1 ### What it does
2 Checks for `a op= a op b` or `a op= b op a` patterns.
3
4 ### Why is this bad?
5 Most likely these are bugs where one meant to write `a
6 op= b`.
7
8 ### Known problems
9 Clippy cannot know for sure if `a op= a op b` should have
10 been `a = a op a op b` or `a = a op b`/`a op= b`. Therefore, it suggests both.
11 If `a op= a op b` is really the correct behavior it should be
12 written as `a = a op a op b` as it's less confusing.
13
14 ### Example
15 ```
16 let mut a = 5;
17 let b = 2;
18 // ...
19 a += a + b;
20 ```