Skip to content

Commit 10fa9c5

Browse files
committed
Simplify
1 parent 8dd0b7d commit 10fa9c5

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

crates/assists/src/handlers/unwrap_block.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
3131

3232
let l_curly_token = ctx.find_token_syntax_at_offset(T!['{'])?;
3333
let mut block = ast::BlockExpr::cast(l_curly_token.parent())?;
34+
let target = block.syntax().text_range();
3435
let mut parent = block.syntax().parent()?;
3536
if ast::MatchArm::can_cast(parent.kind()) {
3637
parent = parent.ancestors().find(|it| ast::MatchExpr::can_cast(it.kind()))?
@@ -48,7 +49,6 @@ pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
4849
// For `else if` blocks
4950
let ancestor_then_branch = ancestor.then_branch()?;
5051

51-
let target = then_branch.syntax().text_range();
5252
return acc.add(assist_id, assist_label, target, |edit| {
5353
let range_to_del_else_if = TextRange::new(
5454
ancestor_then_branch.syntax().text_range().end(),
@@ -68,7 +68,6 @@ pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
6868
});
6969
}
7070
} else {
71-
let target = block.syntax().text_range();
7271
return acc.add(assist_id, assist_label, target, |edit| {
7372
let range_to_del = TextRange::new(
7473
then_branch.syntax().text_range().end(),
@@ -83,7 +82,6 @@ pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
8382
_ => return None,
8483
};
8584

86-
let target = block.syntax().text_range();
8785
let unwrapped = unwrap_trivial_block(block);
8886
acc.add(assist_id, assist_label, target, |builder| {
8987
builder.replace(

0 commit comments

Comments
 (0)