auto merge of #12366 : aepsil0n/rust/feature/unnecessary_parens_around_assigned_values, r=alexcrichton
Fixes #12350. Parentheses around assignment statements such as ```rust let mut a = (0); a = (1); a += (2); ``` are not necessary and therefore an unnecessary_parens warning is raised when statements like this occur. NOTE: In `let` declarations this does not work as intended. Is it possible that they do not count as assignment expressions (`ExprAssign`)? (edit: this is fixed by now) Furthermore, there are some cases that I fixed in the rest of the code, where parentheses could potentially enhance readability. Compare these lines: ```rust a = b == c; a = (b == c); ``` Thus, after having worked on this I'm not entirely sure, whether we should go through with this patch or not. Probably a matter of debate. ;)
This commit is contained in:
commit
eb5ba4d269
15 changed files with 52 additions and 35 deletions
|
|
@ -22,4 +22,7 @@ fn main() {
|
|||
match (true) { //~ ERROR unnecessary parentheses around `match` head expression
|
||||
_ => {}
|
||||
}
|
||||
let mut _a = (0); //~ ERROR unnecessary parentheses around assigned value
|
||||
_a = (0); //~ ERROR unnecessary parentheses around assigned value
|
||||
_a += (1); //~ ERROR unnecessary parentheses around assigned value
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue