diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-21 16:57:49 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-21 16:57:49 +0000 |
commit | c8a73fe655f7bf9778deeec4c8b4b541e0af398b (patch) | |
tree | f6f9a11b950e001505a3c711f59d34620a037684 /crates/assists/src/utils.rs | |
parent | 71c8073aa1e2cd3101a031a4f10e460013d4df74 (diff) | |
parent | 2e7abf83844ef0c7d807262a682941f2aef9d3d9 (diff) |
Merge #6982
6982: Remove parentheses when inverting `!(cond)` r=matklad a=Jesse-Bakker
Followup to #6894
When inverting a composite condition twice, the parentheses were left. This also removes those unnecessary parentheses when applying the invert-if assist.
Co-authored-by: Jesse Bakker <[email protected]>
Diffstat (limited to 'crates/assists/src/utils.rs')
-rw-r--r-- | crates/assists/src/utils.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/assists/src/utils.rs b/crates/assists/src/utils.rs index f2cacf7c8..d41084b59 100644 --- a/crates/assists/src/utils.rs +++ b/crates/assists/src/utils.rs | |||
@@ -232,7 +232,13 @@ fn invert_special_case(expr: &ast::Expr) -> Option<ast::Expr> { | |||
232 | }; | 232 | }; |
233 | Some(make::expr_method_call(receiver, method, arg_list)) | 233 | Some(make::expr_method_call(receiver, method, arg_list)) |
234 | } | 234 | } |
235 | ast::Expr::PrefixExpr(pe) if pe.op_kind()? == ast::PrefixOp::Not => pe.expr(), | 235 | ast::Expr::PrefixExpr(pe) if pe.op_kind()? == ast::PrefixOp::Not => { |
236 | if let ast::Expr::ParenExpr(parexpr) = pe.expr()? { | ||
237 | parexpr.expr() | ||
238 | } else { | ||
239 | pe.expr() | ||
240 | } | ||
241 | } | ||
236 | // FIXME: | 242 | // FIXME: |
237 | // ast::Expr::Literal(true | false ) | 243 | // ast::Expr::Literal(true | false ) |
238 | _ => None, | 244 | _ => None, |