From f7a4a87de2840789e12722afc7df9f4db2db013c Mon Sep 17 00:00:00 2001 From: lbrande Date: Fri, 19 Feb 2021 14:48:07 +0100 Subject: De Morgan's Law assist now correctly parenthesizes binary expressions. --- crates/ide_assists/src/utils.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'crates/ide_assists/src/utils.rs') 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::BinExpr(bin) => match bin.op_kind()? { ast::BinOp::NegatedEqualityTest => bin.replace_op(T![==]).map(|it| it.into()), ast::BinOp::EqualityTest => bin.replace_op(T![!=]).map(|it| it.into()), - // Parenthesize composite boolean expressions before prefixing `!` - ast::BinOp::BooleanAnd | ast::BinOp::BooleanOr => { - Some(make::expr_prefix(T![!], make::expr_paren(expr.clone()))) - } - _ => None, + // Parenthesize other expressions before prefixing `!` + _ => Some(make::expr_prefix(T![!], make::expr_paren(expr.clone()))), }, ast::Expr::MethodCallExpr(mce) => { let receiver = mce.receiver()?; -- cgit v1.2.3