mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-30 13:06:28 +03:00
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:
@@ -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
|
||||
} {}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user