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 {
77
77
)
78
78
}
79
79
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
+
80
89
#[ test]
81
90
fn invert_if_remove_inequality ( ) {
82
91
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> {
232
232
} ;
233
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
242
// FIXME:
237
243
// ast::Expr::Literal(true | false )
238
244
_ => None ,
You can’t perform that action at this time.
0 commit comments