Skip to content

Conversation

@A4-Tacks
Copy link
Member

  • Support else completion in ArrayExpr, ReturnExpr and PrefixExpr etc
  • Support else completion after MatchArm expression

Before this PR, the else branch could not be completed in most expressions

Example

fn foo() -> [i32; 1] {
    [if true {
        2
    } $0]
}

->

fn foo() -> [i32; 1] {
    [if true {
        2
    } else {
        $0
    }]
}

fn foo() -> i32 {
    match () {
        () => if true {
            2
        } $0
    }
}

->

fn foo() -> i32 {
    match () {
        () => if true {
            2
        } else {
            $0
        }
    }
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 12, 2025
@A4-Tacks A4-Tacks changed the title Support else completion for more expressions Fix else completion for more expressions Sep 26, 2025
- Support else completion in ArrayExpr, ReturnExpr and PrefixExpr etc
- Support else completion after MatchArm expression

Before this PR, the else branch could not be completed in most expressions

Example
---
```rust
fn foo() -> [i32; 1] {
    [if true {
        2
    } $0]
}
```
->
```rust
fn foo() -> [i32; 1] {
    [if true {
        2
    } else {
        $0
    }]
}
```

---

```rust
fn foo() -> i32 {
    match () {
        () => if true {
            2
        } $0
    }
}
```
->
```rust
fn foo() -> i32 {
    match () {
        () => if true {
            2
        } else {
            $0
        }
    }
}
```
@A4-Tacks A4-Tacks force-pushed the more-expr-else-after-if branch from e010f46 to b96babe Compare October 24, 2025 02:06
@A4-Tacks
Copy link
Member Author

r? @ShoyuVanilla

Copy link
Member

@ShoyuVanilla ShoyuVanilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ShoyuVanilla ShoyuVanilla added this pull request to the merge queue Oct 24, 2025
Merged via the queue into rust-lang:master with commit 30cd10a Oct 24, 2025
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 24, 2025
@A4-Tacks A4-Tacks deleted the more-expr-else-after-if branch October 24, 2025 04:39
@lnicola lnicola changed the title Fix else completion for more expressions fix: complete else in more expressions Oct 24, 2025
mendelsshop pushed a commit to mendelsshop/rust-analyzer that referenced this pull request Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants