@@ -692,7 +692,14 @@ impl FunctionBody {
692
692
( constness, expr. clone( ) , infer_expr_opt( expr) )
693
693
} ,
694
694
ast:: Fn ( fn_) => {
695
- ( fn_. const_token( ) . is_some( ) , fn_. body( ) . map( ast:: Expr :: BlockExpr ) , Some ( sema. to_def( & fn_) ?. ret_type( sema. db) ) )
695
+ let func = sema. to_def( & fn_) ?;
696
+ let mut ret_ty = func. ret_type( sema. db) ;
697
+ if func. is_async( sema. db) {
698
+ if let Some ( async_ret) = func. async_ret_type( sema. db) {
699
+ ret_ty = async_ret;
700
+ }
701
+ }
702
+ ( fn_. const_token( ) . is_some( ) , fn_. body( ) . map( ast:: Expr :: BlockExpr ) , Some ( ret_ty) )
696
703
} ,
697
704
ast:: Static ( statik) => {
698
705
( true , statik. body( ) , Some ( sema. to_def( & statik) ?. ty( sema. db) ) )
@@ -4026,6 +4033,7 @@ fn $0fun_name(n: i32) -> i32 {
4026
4033
check_assist (
4027
4034
extract_function,
4028
4035
r#"
4036
+ //- minicore: future
4029
4037
fn main() {
4030
4038
$0some_function().await;$0
4031
4039
}
@@ -4055,6 +4063,7 @@ async fn some_function() {
4055
4063
check_assist (
4056
4064
extract_function,
4057
4065
r#"
4066
+ //- minicore: future, result
4058
4067
async fn foo() -> Result<(), ()> {
4059
4068
$0async {}.await;
4060
4069
Err(())?$0
@@ -4065,7 +4074,7 @@ async fn foo() -> Result<(), ()> {
4065
4074
fun_name().await?
4066
4075
}
4067
4076
4068
- async fn $0fun_name() -> _ {
4077
+ async fn $0fun_name() -> Result<(), ()> {
4069
4078
async {}.await;
4070
4079
Err(())?
4071
4080
}
@@ -4078,6 +4087,7 @@ async fn $0fun_name() -> _ {
4078
4087
check_assist (
4079
4088
extract_function,
4080
4089
r#"
4090
+ //- minicore: future
4081
4091
async fn foo() -> i32 {
4082
4092
loop {
4083
4093
let n = 1;$0
@@ -4119,6 +4129,7 @@ async fn $0fun_name() -> Result<i32, i32> {
4119
4129
check_assist (
4120
4130
extract_function,
4121
4131
r#"
4132
+ //- minicore: future
4122
4133
fn main() {
4123
4134
$0function_call("a", some_function().await);$0
4124
4135
}
0 commit comments