diff options
author | lbrande <[email protected]> | 2021-02-19 13:48:07 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-02-24 10:58:37 +0000 |
commit | f7a4a87de2840789e12722afc7df9f4db2db013c (patch) | |
tree | cbc35e6f34db1216977269d7077d5a1889a41b86 /crates/ide_assists/src/utils.rs | |
parent | aa38fa1c72673cb2470651025782fb0fcfad738c (diff) |
De Morgan's Law assist now correctly parenthesizes binary expressions.
Diffstat (limited to 'crates/ide_assists/src/utils.rs')
-rw-r--r-- | crates/ide_assists/src/utils.rs | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/crates/ide_assists/src/utils.rs b/crates/ide_assists/src/utils.rs index 0074da741..cd026d432 100644 --- a/crates/ide_assists/src/utils.rs +++ b/crates/ide_assists/src/utils.rs | |||
@@ -217,11 +217,8 @@ fn invert_special_case(expr: &ast::Expr) -> Option<ast::Expr> { | |||
217 | ast::Expr::BinExpr(bin) => match bin.op_kind()? { | 217 | ast::Expr::BinExpr(bin) => match bin.op_kind()? { |
218 | ast::BinOp::NegatedEqualityTest => bin.replace_op(T![==]).map(|it| it.into()), | 218 | ast::BinOp::NegatedEqualityTest => bin.replace_op(T![==]).map(|it| it.into()), |
219 | ast::BinOp::EqualityTest => bin.replace_op(T![!=]).map(|it| it.into()), | 219 | ast::BinOp::EqualityTest => bin.replace_op(T![!=]).map(|it| it.into()), |
220 | // Parenthesize composite boolean expressions before prefixing `!` | 220 | // Parenthesize other expressions before prefixing `!` |
221 | ast::BinOp::BooleanAnd | ast::BinOp::BooleanOr => { | 221 | _ => Some(make::expr_prefix(T![!], make::expr_paren(expr.clone()))), |
222 | Some(make::expr_prefix(T![!], make::expr_paren(expr.clone()))) | ||
223 | } | ||
224 | _ => None, | ||
225 | }, | 222 | }, |
226 | ast::Expr::MethodCallExpr(mce) => { | 223 | ast::Expr::MethodCallExpr(mce) => { |
227 | let receiver = mce.receiver()?; | 224 | let receiver = mce.receiver()?; |