Skip to content

fix: keep comments for 'Fill match arms'#21744

Open
A4-Tacks wants to merge 1 commit intorust-lang:masterfrom
A4-Tacks:add-match-arms-inc-edit
Open

fix: keep comments for 'Fill match arms'#21744
A4-Tacks wants to merge 1 commit intorust-lang:masterfrom
A4-Tacks:add-match-arms-inc-edit

Conversation

@A4-Tacks
Copy link
Member

@A4-Tacks A4-Tacks commented Mar 4, 2026

Fixes #21718

Example

enum E { A, B, C }

fn foo(t: E) -> i32 {
    match $0t {
        // variant a
        E::A => 2
        // comment on end
    }
}

Before this PR

enum E { A, B, C }

fn foo(t: E) -> i32 {
    match t {
        E::A => 2,
        E::B => ${1:todo!()},
        E::C => ${2:todo!()},$0
    }
}

After this PR

enum E { A, B, C }

fn foo(t: E) -> i32 {
    match t {
        // variant a
        E::A => 2,
        // comment on end
        E::B => ${1:todo!()},
        E::C => ${2:todo!()},$0
    }
}

Example
---
```rust
enum E { A, B, C }

fn foo(t: E) -> i32 {
    match $0t {
        // variant a
        E::A => 2
        // comment on end
    }
}
```

**Before this PR**

```rust
enum E { A, B, C }

fn foo(t: E) -> i32 {
    match t {
        E::A => 2,
        E::B => ${1:todo!()},
        E::C => ${2:todo!()},$0
    }
}
```

**After this PR**

```rust
enum E { A, B, C }

fn foo(t: E) -> i32 {
    match t {
        // variant a
        E::A => 2,
        // comment on end
        E::B => ${1:todo!()},
        E::C => ${2:todo!()},$0
    }
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'Fill match arms' for enum deletes existing comments

2 participants