File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
src/tools/rust-analyzer/crates
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 {
124124 )
125125 }
126126
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+
127139 #[ test]
128140 fn invert_if_option_case ( ) {
129141 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 {
265265 ast:: Expr :: BinExpr ( expr)
266266 if expr. op_kind ( ) == Some ( ast:: BinaryOp :: LogicOp ( ast:: LogicOp :: And ) ) =>
267267 {
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)
272269 }
273270 ast:: Expr :: ParenExpr ( expr) => expr. expr ( ) . is_some_and ( is_pattern_cond) ,
274271 ast:: Expr :: LetExpr ( _) => true ,
You can’t perform that action at this time.
0 commit comments