From 2e7abf83844ef0c7d807262a682941f2aef9d3d9 Mon Sep 17 00:00:00 2001 From: Jesse Bakker Date: Mon, 21 Dec 2020 17:37:38 +0100 Subject: Remove parentheses when inverting `!(cond)` --- crates/assists/src/utils.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/assists/src/utils.rs') 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 { }; Some(make::expr_method_call(receiver, method, arg_list)) } - ast::Expr::PrefixExpr(pe) if pe.op_kind()? == ast::PrefixOp::Not => pe.expr(), + ast::Expr::PrefixExpr(pe) if pe.op_kind()? == ast::PrefixOp::Not => { + if let ast::Expr::ParenExpr(parexpr) = pe.expr()? { + parexpr.expr() + } else { + pe.expr() + } + } // FIXME: // ast::Expr::Literal(true | false ) _ => None, -- cgit v1.2.3