feat: offer 'add_braces' on bin-expr assignment

Example
---
```rust
fn foo() {
    let x;
    x =$0 n + 100;
}
```

**Before this PR**

Assist not applicable

**After this PR**

```rust
fn foo() {
    let x;
    x = {
        n + 100
    };
}
```
This commit is contained in:
A4-Tacks
2026-03-21 16:16:03 +08:00
parent 9bff35bd80
commit dc8d64dbd4
@@ -84,6 +84,7 @@ fn get_replacement_node(ctx: &AssistContext<'_>) -> Option<(ParentType, ast::Exp
match parent {
ast::LetStmt(it) => it.initializer()?,
ast::LetExpr(it) => it.expr()?,
ast::BinExpr(it) => it.rhs()?,
ast::Static(it) => it.body()?,
ast::Const(it) => it.body()?,
_ => return None,
@@ -192,6 +193,22 @@ fn foo() {
n + 100
};
}
"#,
);
check_assist(
add_braces,
r#"
fn foo() {
if let x =$0 n + 100 {}
}
"#,
r#"
fn foo() {
if let x = {
n + 100
} {}
}
"#,
);
}