File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
crates/ra_assists/src/handlers Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,11 @@ pub(crate) fn invert_if(ctx: AssistCtx) -> Option<Assist> {
33
33
return None ;
34
34
}
35
35
36
+ // This assist should not apply for if-let.
37
+ if expr. condition ( ) ?. pat ( ) . is_some ( ) {
38
+ return None ;
39
+ }
40
+
36
41
let cond = expr. condition ( ) ?. expr ( ) ?;
37
42
let then_node = expr. then_branch ( ) ?. syntax ( ) . clone ( ) ;
38
43
@@ -90,4 +95,12 @@ mod tests {
90
95
fn invert_if_doesnt_apply_with_cursor_not_on_if ( ) {
91
96
check_assist_not_applicable ( invert_if, "fn f() { if !<|>cond { 3 * 2 } else { 1 } }" )
92
97
}
98
+
99
+ #[ test]
100
+ fn invert_if_doesnt_apply_with_if_let ( ) {
101
+ check_assist_not_applicable (
102
+ invert_if,
103
+ "fn f() { i<|>f let Some(_) = Some(1) { 1 } else { 0 } }" ,
104
+ )
105
+ }
93
106
}
You can’t perform that action at this time.
0 commit comments