mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-21 19:33:16 +00:00
disable invert if assist for if-let to fix #3281
This commit is contained in:
parent
10867336e6
commit
c3702a6b71
@ -33,6 +33,11 @@ pub(crate) fn invert_if(ctx: AssistCtx) -> Option<Assist> {
|
||||
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 } }",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user