diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-09-02 20:20:24 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-09-02 20:20:24 +0100 |
commit | 7faec1c30046769d4ae490e15cf5405bcfbdeef8 (patch) | |
tree | 6d268b721027a5350928a6c5a0ec227b5fde8ebc /crates/ra_assists/src/move_guard.rs | |
parent | a8397deab914240aca8f015fb3736689919c0a5b (diff) | |
parent | e94587e3153b52684fd3f6b82c8e7efc09ff5c8d (diff) |
Merge #1752
1752: Always wrap blocks into block expressions r=flodiebold a=matklad
This way, things like function bodies are expressions, and we don't have to single them out
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/move_guard.rs')
-rw-r--r-- | crates/ra_assists/src/move_guard.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/ra_assists/src/move_guard.rs b/crates/ra_assists/src/move_guard.rs index 127c9e068..699221e33 100644 --- a/crates/ra_assists/src/move_guard.rs +++ b/crates/ra_assists/src/move_guard.rs | |||
@@ -65,9 +65,9 @@ pub(crate) fn move_arm_cond_to_match_guard(mut ctx: AssistCtx<impl HirDatabase>) | |||
65 | "move condition to match guard", | 65 | "move condition to match guard", |
66 | |edit| { | 66 | |edit| { |
67 | edit.target(if_expr.syntax().text_range()); | 67 | edit.target(if_expr.syntax().text_range()); |
68 | let then_only_expr = then_block.statements().next().is_none(); | 68 | let then_only_expr = then_block.block().and_then(|it| it.statements().next()).is_none(); |
69 | 69 | ||
70 | match &then_block.expr() { | 70 | match &then_block.block().and_then(|it| it.expr()) { |
71 | Some(then_expr) if then_only_expr => { | 71 | Some(then_expr) if then_only_expr => { |
72 | edit.replace(if_expr.syntax().text_range(), then_expr.syntax().text()) | 72 | edit.replace(if_expr.syntax().text_range(), then_expr.syntax().text()) |
73 | } | 73 | } |