diff options
author | Daiki Ihara <[email protected]> | 2021-06-17 15:54:49 +0100 |
---|---|---|
committer | Daiki Ihara <[email protected]> | 2021-06-21 10:31:53 +0100 |
commit | cd1ef8de1829d7ec17015f5cd02b476cd0d1d889 (patch) | |
tree | 6f55d82065d6e79cf93e1b6493ab9266d9985e0a /crates | |
parent | 3898387f3bd579c0c5415ecb7c7b3d3923947f2f (diff) |
Fix extract_function with await
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide_assists/src/handlers/extract_function.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs index ac7f0959b..62edc4850 100644 --- a/crates/ide_assists/src/handlers/extract_function.rs +++ b/crates/ide_assists/src/handlers/extract_function.rs | |||
@@ -994,6 +994,9 @@ fn format_replacement(ctx: &AssistContext, fun: &Function, indent: IndentLevel) | |||
994 | } | 994 | } |
995 | } | 995 | } |
996 | format_to!(buf, "{}", expr); | 996 | format_to!(buf, "{}", expr); |
997 | if body_contains_await(&fun.body) { | ||
998 | buf.push_str(".await"); | ||
999 | } | ||
997 | if fun.ret_ty.is_unit() | 1000 | if fun.ret_ty.is_unit() |
998 | && (!fun.vars_defined_in_body_and_outlive.is_empty() || !expr.is_block_like()) | 1001 | && (!fun.vars_defined_in_body_and_outlive.is_empty() || !expr.is_block_like()) |
999 | { | 1002 | { |
@@ -3681,7 +3684,7 @@ async fn some_function() { | |||
3681 | "#, | 3684 | "#, |
3682 | r#" | 3685 | r#" |
3683 | fn main() { | 3686 | fn main() { |
3684 | fun_name(); | 3687 | fun_name().await; |
3685 | } | 3688 | } |
3686 | 3689 | ||
3687 | async fn $0fun_name() { | 3690 | async fn $0fun_name() { |
@@ -3710,7 +3713,7 @@ async fn some_function() { | |||
3710 | "#, | 3713 | "#, |
3711 | r#" | 3714 | r#" |
3712 | fn main() { | 3715 | fn main() { |
3713 | fun_name(); | 3716 | fun_name().await; |
3714 | } | 3717 | } |
3715 | 3718 | ||
3716 | async fn $0fun_name() { | 3719 | async fn $0fun_name() { |