File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,15 @@ mod tests {
7777 )
7878 }
7979
80+ #[ test]
81+ fn invert_if_remove_not_parentheses ( ) {
82+ check_assist (
83+ invert_if,
84+ "fn f() { i<|>f !(x == 3 || x == 4 || x == 5) { 3 * 2 } else { 1 } }" ,
85+ "fn f() { if x == 3 || x == 4 || x == 5 { 1 } else { 3 * 2 } }" ,
86+ )
87+ }
88+
8089 #[ test]
8190 fn invert_if_remove_inequality ( ) {
8291 check_assist (
Original file line number Diff line number Diff line change @@ -232,7 +232,13 @@ fn invert_special_case(expr: &ast::Expr) -> Option<ast::Expr> {
232232 } ;
233233 Some ( make:: expr_method_call ( receiver, method, arg_list) )
234234 }
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+ }
236242 // FIXME:
237243 // ast::Expr::Literal(true | false )
238244 _ => None ,
You can’t perform that action at this time.
0 commit comments