File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
ide-db/src/syntax_helpers Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,18 @@ mod tests {
124
124
)
125
125
}
126
126
127
+ #[ test]
128
+ fn invert_if_doesnt_apply_with_if_let_chain ( ) {
129
+ check_assist_not_applicable (
130
+ invert_if,
131
+ "fn f() { i$0f x && let Some(_) = Some(1) { 1 } else { 0 } }" ,
132
+ ) ;
133
+ check_assist_not_applicable (
134
+ invert_if,
135
+ "fn f() { i$0f let Some(_) = Some(1) && x { 1 } else { 0 } }" ,
136
+ ) ;
137
+ }
138
+
127
139
#[ test]
128
140
fn invert_if_option_case ( ) {
129
141
check_assist (
Original file line number Diff line number Diff line change @@ -265,10 +265,7 @@ pub fn is_pattern_cond(expr: ast::Expr) -> bool {
265
265
ast:: Expr :: BinExpr ( expr)
266
266
if expr. op_kind ( ) == Some ( ast:: BinaryOp :: LogicOp ( ast:: LogicOp :: And ) ) =>
267
267
{
268
- expr. lhs ( )
269
- . map ( is_pattern_cond)
270
- . or_else ( || expr. rhs ( ) . map ( is_pattern_cond) )
271
- . unwrap_or ( false )
268
+ expr. lhs ( ) . map_or ( false , is_pattern_cond) || expr. rhs ( ) . map_or ( false , is_pattern_cond)
272
269
}
273
270
ast:: Expr :: ParenExpr ( expr) => expr. expr ( ) . is_some_and ( is_pattern_cond) ,
274
271
ast:: Expr :: LetExpr ( _) => true ,
You can’t perform that action at this time.
0 commit comments