Skip to content

Migrate unwrap_block assist to use SyntaxEditor#21458

Merged
ShoyuVanilla merged 1 commit intorust-lang:masterfrom
A4-Tacks:migrate-unwrap-block
Jan 14, 2026
Merged

Migrate unwrap_block assist to use SyntaxEditor#21458
ShoyuVanilla merged 1 commit intorust-lang:masterfrom
A4-Tacks:migrate-unwrap-block

Conversation

@A4-Tacks
Copy link
Member

  • Fix invalid match in let-stmt
  • Fix multiple statements loses indent

Example

fn main() {
    let value = match rel_path {
        Ok(rel_path) => {$0
            let rel_path = RelativePathBuf::from_path(rel_path).ok()?;
            Some((*id, rel_path))
        }
        Err(_) => None,
    };
}

Before this PR

fn main() {
    let value = let rel_path = RelativePathBuf::from_path(rel_path).ok()?;
    let value = Some((*id, rel_path));
}

After this PR

fn main() {
    let rel_path = RelativePathBuf::from_path(rel_path).ok()?;
    let value = Some((*id, rel_path));
}

fn main() {
    let mut a = {$0
        1;
        2;
        3
    };
}

Before this PR

fn main() {
    1;
2;
    let mut a = 3;
}

After this PR

fn main() -> i32 {
    1;
    2;
    let mut a = 3;
}

- Fix invalid match in let-stmt
- Fix multiple statements loses indent

Example
---
```rust
fn main() {
    let value = match rel_path {
        Ok(rel_path) => {$0
            let rel_path = RelativePathBuf::from_path(rel_path).ok()?;
            Some((*id, rel_path))
        }
        Err(_) => None,
    };
}
```

**Before this PR**

```rust
fn main() {
    let value = let rel_path = RelativePathBuf::from_path(rel_path).ok()?;
    let value = Some((*id, rel_path));
}
```

**After this PR**

```rust
fn main() {
    let rel_path = RelativePathBuf::from_path(rel_path).ok()?;
    let value = Some((*id, rel_path));
}
```

---

```rust
fn main() {
    let mut a = {$0
        1;
        2;
        3
    };
}
```

**Before this PR**

```rust
fn main() {
    1;
2;
    let mut a = 3;
}
```

**After this PR**

```rust
fn main() -> i32 {
    1;
    2;
    let mut a = 3;
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 13, 2026
@ShoyuVanilla ShoyuVanilla added this pull request to the merge queue Jan 14, 2026
Merged via the queue into rust-lang:master with commit a2a39d1 Jan 14, 2026
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 14, 2026
@A4-Tacks A4-Tacks deleted the migrate-unwrap-block branch January 15, 2026 09:52
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.

4 participants