From c3702a6b7143ca6e6186f3c0c07589ddd71b20fb Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Sat, 21 Mar 2020 06:40:18 -0700 Subject: disable invert if assist for if-let to fix #3281 --- crates/ra_assists/src/handlers/invert_if.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'crates') diff --git a/crates/ra_assists/src/handlers/invert_if.rs b/crates/ra_assists/src/handlers/invert_if.rs index 3a2665d17..4c5716868 100644 --- a/crates/ra_assists/src/handlers/invert_if.rs +++ b/crates/ra_assists/src/handlers/invert_if.rs @@ -33,6 +33,11 @@ pub(crate) fn invert_if(ctx: AssistCtx) -> Option { return None; } + // This assist should not apply for if-let. + if expr.condition()?.pat().is_some() { + return None; + } + let cond = expr.condition()?.expr()?; let then_node = expr.then_branch()?.syntax().clone(); @@ -90,4 +95,12 @@ mod tests { fn invert_if_doesnt_apply_with_cursor_not_on_if() { check_assist_not_applicable(invert_if, "fn f() { if !<|>cond { 3 * 2 } else { 1 } }") } + + #[test] + fn invert_if_doesnt_apply_with_if_let() { + check_assist_not_applicable( + invert_if, + "fn f() { i<|>f let Some(_) = Some(1) { 1 } else { 0 } }", + ) + } } -- cgit v1.2.3