diff options
author | cynecx <[email protected]> | 2021-05-29 17:16:20 +0100 |
---|---|---|
committer | cynecx <[email protected]> | 2021-05-29 17:17:45 +0100 |
commit | 54d60fdee9a49e2081837cc6445c61dec0b303af (patch) | |
tree | 7ace97cb1ee22e99fdbb1ecaca531ffdbaffdada /crates/hir_def/src/item_tree | |
parent | 3fa3343e4747c3f7b2ca3e7924ba5286d67af87c (diff) |
hir_ty: use async ret type for inference inside async bodies
Diffstat (limited to 'crates/hir_def/src/item_tree')
-rw-r--r-- | crates/hir_def/src/item_tree/lower.rs | 8 | ||||
-rw-r--r-- | crates/hir_def/src/item_tree/pretty.rs | 1 |
2 files changed, 6 insertions, 3 deletions
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index b83adec46..6208facd5 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs | |||
@@ -356,12 +356,13 @@ impl<'a> Ctx<'a> { | |||
356 | _ => TypeRef::unit(), | 356 | _ => TypeRef::unit(), |
357 | }; | 357 | }; |
358 | 358 | ||
359 | let ret_type = if func.async_token().is_some() { | 359 | let (ret_type, async_ret_type) = if func.async_token().is_some() { |
360 | let async_ret_type = ret_type.clone(); | ||
360 | let future_impl = desugar_future_path(ret_type); | 361 | let future_impl = desugar_future_path(ret_type); |
361 | let ty_bound = Interned::new(TypeBound::Path(future_impl)); | 362 | let ty_bound = Interned::new(TypeBound::Path(future_impl)); |
362 | TypeRef::ImplTrait(vec![ty_bound]) | 363 | (TypeRef::ImplTrait(vec![ty_bound]), Some(async_ret_type)) |
363 | } else { | 364 | } else { |
364 | ret_type | 365 | (ret_type, None) |
365 | }; | 366 | }; |
366 | 367 | ||
367 | let abi = func.abi().map(lower_abi); | 368 | let abi = func.abi().map(lower_abi); |
@@ -395,6 +396,7 @@ impl<'a> Ctx<'a> { | |||
395 | abi, | 396 | abi, |
396 | params, | 397 | params, |
397 | ret_type: Interned::new(ret_type), | 398 | ret_type: Interned::new(ret_type), |
399 | async_ret_type: async_ret_type.map(Interned::new), | ||
398 | ast_id, | 400 | ast_id, |
399 | flags, | 401 | flags, |
400 | }; | 402 | }; |
diff --git a/crates/hir_def/src/item_tree/pretty.rs b/crates/hir_def/src/item_tree/pretty.rs index d1ee697cb..cc9944a22 100644 --- a/crates/hir_def/src/item_tree/pretty.rs +++ b/crates/hir_def/src/item_tree/pretty.rs | |||
@@ -235,6 +235,7 @@ impl<'a> Printer<'a> { | |||
235 | abi, | 235 | abi, |
236 | params, | 236 | params, |
237 | ret_type, | 237 | ret_type, |
238 | async_ret_type: _, | ||
238 | ast_id: _, | 239 | ast_id: _, |
239 | flags, | 240 | flags, |
240 | } = &self.tree[it]; | 241 | } = &self.tree[it]; |