From cd1ef8de1829d7ec17015f5cd02b476cd0d1d889 Mon Sep 17 00:00:00 2001 From: Daiki Ihara Date: Thu, 17 Jun 2021 23:54:49 +0900 Subject: Fix extract_function with await --- crates/ide_assists/src/handlers/extract_function.rs | 7 +++++-- 1 file 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) } } format_to!(buf, "{}", expr); + if body_contains_await(&fun.body) { + buf.push_str(".await"); + } if fun.ret_ty.is_unit() && (!fun.vars_defined_in_body_and_outlive.is_empty() || !expr.is_block_like()) { @@ -3681,7 +3684,7 @@ async fn some_function() { "#, r#" fn main() { - fun_name(); + fun_name().await; } async fn $0fun_name() { @@ -3710,7 +3713,7 @@ async fn some_function() { "#, r#" fn main() { - fun_name(); + fun_name().await; } async fn $0fun_name() { -- cgit v1.2.3