Skip to content

Conversation

@A4-Tacks
Copy link
Member

Example

fn main() {
    match 92 {
        x @ 0..30 $0if x % 3 == 0 => false,
        x @ 0..30 if x % 2 == 0 => true,
        _ => false
    }
}

Before this PR

fn main() {
    match 92 {
        x @ 0..30 => if x % 3 == 0 {
            false
        },
        x @ 0..30 if x % 2 == 0 => true,
        _ => false
    }
}

After this PR

fn main() {
    match 92 {
        x @ 0..30 => if x % 3 == 0 {
            false
        } else if x % 2 == 0 {
            true
        },
        _ => false
    }
}

Example
---
```rust
fn main() {
    match 92 {
        x @ 0..30 $0if x % 3 == 0 => false,
        x @ 0..30 if x % 2 == 0 => true,
        _ => false
    }
}
```

**Before this PR**

```rust
fn main() {
    match 92 {
        x @ 0..30 => if x % 3 == 0 {
            false
        },
        x @ 0..30 if x % 2 == 0 => true,
        _ => false
    }
}
```

**After this PR**

```rust
fn main() {
    match 92 {
        x @ 0..30 => if x % 3 == 0 {
            false
        } else if x % 2 == 0 {
            true
        },
        _ => false
    }
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 22, 2026
Copy link
Contributor

@ChayimFriedman2 ChayimFriedman2 left a comment

Choose a reason for hiding this comment

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

This will transform the code wrongly if the user is selecting the non-first arm.

Other than that, LGTM.

@A4-Tacks
Copy link
Member Author

This will transform the code wrongly if the user is selecting the non-first arm.

From testing, it is expected

@ChayimFriedman2
Copy link
Contributor

I meant where there is an empty selection, so all matching arms are eligible, but we'll reorder them to put the arm where the cursor is first.

@A4-Tacks
Copy link
Member Author

I meant where there is an empty selection, so all matching arms are eligible

Why are we doing this? The current logic is consistent with Merge match arms

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.

3 participants