This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Expand file tree Collapse file tree 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> {
386386 self . print_type_ref ( ret_ty) ;
387387 }
388388 ( None , ClosureKind :: Async ) => {
389- w ! ( self , " -> impl Future<Output = {{unknown}}>" ) ; // FIXME(zachs18): {unknown} or ()?
389+ w ! ( self , " -> impl Future<Output = {{unknown}}>" ) ;
390390 }
391391 ( None , _) => { }
392392 }
Original file line number Diff line number Diff line change @@ -82,6 +82,46 @@ async fn test() {
8282 ) ;
8383}
8484
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+
85125#[ test]
86126fn auto_sized_async_block ( ) {
87127 check_no_mismatches (
You can’t perform that action at this time.
0 commit comments