Repository: intellij-rust/intellij-rust
Issue: Wrong type is interfered for closure which returns async block

## Environment

* **IntelliJ Rust plugin version:** 0.2.105.2133-192
* **Rust toolchain version:** nightly-x86_64-apple-darwin (default) rustc 1.39.0-nightly (43a5ff422 2019-09-07)
* **IDE name and version:** IntelliJ IDEA 2019.2.2 (Community Edition)
Build #IC-192.6603.28, built on September 6, 2019
Runtime version: 11.0.3+12-b304.56 x86_64
* **Operating system:** macOS 10.14.6

## Problem description

For a closure like

```rust
let fut = || async {
    5
};
```

the following type is interfered: `fn() -> i32`. 
However the correct type would be: `fn() -> impl Future<Output=i32>`.

Surprisingly without the closure the correct type is interfered:

```rust
let fut = async {
    5
};
```

resolves `fut` as: `impl Future<Output=i32>`

Changed files:
src/test/kotlin/org/rust/lang/core/type/RsExpressionTypeInferenceTest.kt, src/main/kotlin/org/rust/lang/core/types/infer/TypeInferenceWalker.kt

diff --git a/src/main/kotlin/org/rust/lang/core/types/infer/TypeInferenceWalker.kt b/src/main/kotlin/org/rust/lang/core/types/infer/TypeInferenceWalker.kt
index a723ae4b9..cae42a560 100644
--- a/src/main/kotlin/org/rust/lang/core/types/infer/TypeInferenceWalker.kt
+++ b/src/main/kotlin/org/rust/lang/core/types/infer/TypeInferenceWalker.kt
@@ -82,14 +82,7 @@ class RsTypeInferenceWalker(
     fun inferFnBody(block: RsBlock): Ty =
         block.inferTypeCoercableTo(returnTy)
 
-    fun inferLambdaBody(expr: RsExpr): Ty =
-        if (expr is RsBlockExpr) {
-            // skipping diverging procession for lambda body
-            ctx.writeExprTy(expr, returnTy)
-            inferFnBody(expr.block)
-        } else {
-            expr.inferTypeCoercableTo(returnTy)
-        }
+    fun inferLambdaBody(expr: RsExpr): Ty = expr.inferTypeCoercableTo(returnTy)
 
     private fun RsBlock.inferTypeCoercableTo(expected: Ty): Ty =
         inferType(expected, true)
diff --git a/src/test/kotlin/org/rust/lang/core/type/RsExpressionTypeInferenceTest.kt b/src/test/kotlin/org/rust/lang/core/type/RsExpressionTypeInferenceTest.kt
index 6a32f517b..ed73bd362 100644
--- a/src/test/kotlin/org/rust/lang/core/type/RsExpressionTypeInferenceTest.kt
+++ b/src/test/kotlin/org/rust/lang/core/type/RsExpressionTypeInferenceTest.kt
@@ -207,6 +207,39 @@ class RsExpressionTypeInferenceTest : RsTypificationTestBase() {
         }
     """)
 
+    fun `test lambda async expr`() = testExpr("""
+        #[lang = "core::future::future::Future"]
+        trait Future { type Output; }
+        fn main() {
+            let x = || async { 42 };
+            x;
+          //^ fn() -> impl Future<Output=i32>
+        }
+    """)
+
+    fun `test async lambda async expr`() = testExpr("""
+        #[lang = "core::future::future::Future"]
+        trait Future { type Output; }
+        fn main() {
+            let x = async || async { 42 };
+            x;
+          //^ fn() -> impl Future<Output=impl Future<Output=i32>>
+        }
+    """)
+
+    fun `test lambda try expr`() = testExpr("""
+        #[lang = "core::option::Option"]
+        enum Option<T> { None, Some(T) }
+        #[lang = "core::ops::try::Try"]
+        trait Try { type Ok; type Error; }
+        impl<T> Try for Option<T> { type Ok = T; type Error = (); }
+        fn main() {
+            let x: fn() -> Option<_> = || try { 42 };
+            x;
+          //^ fn() -> Option<i32>
+        }
+    """)
+
     fun `test type parameters`() = testExpr("""
         fn foo<FOO>(foo: FOO) {
             let bar = foo;