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> {
3333 return None ;
3434 }
3535
36+ // This assist should not apply for if-let.
37+ if expr. condition ( ) ?. pat ( ) . is_some ( ) {
38+ return None ;
39+ }
40+
3641 let cond = expr. condition ( ) ?. expr ( ) ?;
3742 let then_node = expr. then_branch ( ) ?. syntax ( ) . clone ( ) ;
3843
@@ -90,4 +95,12 @@ mod tests {
9095 fn invert_if_doesnt_apply_with_cursor_not_on_if ( ) {
9196 check_assist_not_applicable ( invert_if, "fn f() { if !<|>cond { 3 * 2 } else { 1 } }" )
9297 }
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+ }
93106}
You can’t perform that action at this time.
0 commit comments