File tree 2 files changed +41
-1
lines changed
2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -386,7 +386,7 @@ impl<'a> Printer<'a> {
386
386
self . print_type_ref ( ret_ty) ;
387
387
}
388
388
( None , ClosureKind :: Async ) => {
389
- w ! ( self , " -> impl Future<Output = {{unknown}}>" ) ; // FIXME(zachs18): {unknown} or ()?
389
+ w ! ( self , " -> impl Future<Output = {{unknown}}>" ) ;
390
390
}
391
391
( None , _) => { }
392
392
}
Original file line number Diff line number Diff line change @@ -82,6 +82,46 @@ async fn test() {
82
82
) ;
83
83
}
84
84
85
+ #[ test]
86
+ fn infer_async_closure ( ) {
87
+ check_types (
88
+ r#"
89
+ //- minicore: future, option
90
+ async fn test() {
91
+ let f = async move |x: i32| x + 42;
92
+ f;
93
+ // ^ |i32| -> impl Future<Output = i32>
94
+ let a = f(4);
95
+ a;
96
+ // ^ impl Future<Output = i32>
97
+ let x = a.await;
98
+ x;
99
+ // ^ i32
100
+ let f = async move || 42;
101
+ f;
102
+ // ^ || -> impl Future<Output = i32>
103
+ let a = f();
104
+ a;
105
+ // ^ impl Future<Output = i32>
106
+ let x = a.await;
107
+ x;
108
+ // ^ i32
109
+ let b = ((async move || {})()).await;
110
+ b;
111
+ // ^ ()
112
+ let c = async move || {
113
+ let y = None;
114
+ y
115
+ // ^ Option<u64>
116
+ };
117
+ let _: Option<u64> = c().await;
118
+ c;
119
+ // ^ || -> impl Future<Output = Option<u64>>
120
+ }
121
+ "# ,
122
+ ) ;
123
+ }
124
+
85
125
#[ test]
86
126
fn auto_sized_async_block ( ) {
87
127
check_no_mismatches (
You can’t perform that action at this time.
0 commit comments