mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
simplify
This commit is contained in:
parent
d75cacc601
commit
17a1011a12
1 changed files with 6 additions and 8 deletions
|
@ -85,15 +85,13 @@ fn on_opening_brace_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdi
|
||||||
|
|
||||||
// We expect a block expression enclosing exactly 1 preexisting expression. It can be parsed as
|
// We expect a block expression enclosing exactly 1 preexisting expression. It can be parsed as
|
||||||
// either the trailing expr or an ExprStmt.
|
// either the trailing expr or an ExprStmt.
|
||||||
let offset = {
|
let offset = match block.statements().next() {
|
||||||
match block.statements().next() {
|
Some(ast::Stmt::ExprStmt(it)) => {
|
||||||
Some(ast::Stmt::ExprStmt(it)) => {
|
// Use the expression span to place `}` before the `;`
|
||||||
// Use the expression span to place `}` before the `;`
|
it.expr()?.syntax().text_range().end()
|
||||||
it.expr()?.syntax().text_range().end()
|
|
||||||
}
|
|
||||||
None => block.tail_expr()?.syntax().text_range().end(),
|
|
||||||
_ => return None,
|
|
||||||
}
|
}
|
||||||
|
None => block.tail_expr()?.syntax().text_range().end(),
|
||||||
|
_ => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(TextEdit::insert(offset, "}".to_string()))
|
Some(TextEdit::insert(offset, "}".to_string()))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue