File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -6744,13 +6744,19 @@ impl<'a> Parser<'a> {
6744
6744
maybe_append ( attrs, extra_attrs) ) ;
6745
6745
return Ok ( Some ( item) ) ;
6746
6746
}
6747
- if self . check_keyword ( keywords:: Async ) &&
6748
- ( self . look_ahead ( 1 , |t| t. is_keyword ( keywords:: Fn ) ) ||
6749
- self . look_ahead ( 1 , |t| t. is_keyword ( keywords:: Unsafe ) ) )
6747
+
6748
+ // `unsafe async fn` or `async fn`
6749
+ if (
6750
+ self . check_keyword ( keywords:: Unsafe ) &&
6751
+ self . look_ahead ( 1 , |t| t. is_keyword ( keywords:: Async ) )
6752
+ ) || (
6753
+ self . check_keyword ( keywords:: Async ) &&
6754
+ self . look_ahead ( 1 , |t| t. is_keyword ( keywords:: Fn ) )
6755
+ )
6750
6756
{
6751
6757
// ASYNC FUNCTION ITEM
6752
- self . expect_keyword ( keywords:: Async ) ?;
6753
6758
let unsafety = self . parse_unsafety ( ) ;
6759
+ self . expect_keyword ( keywords:: Async ) ?;
6754
6760
self . expect_keyword ( keywords:: Fn ) ?;
6755
6761
let fn_span = self . prev_span ;
6756
6762
let ( ident, item_, extra_attrs) =
Original file line number Diff line number Diff line change @@ -99,6 +99,19 @@ fn async_fn_with_internal_borrow(y: u8) -> impl Future<Output = u8> {
99
99
}
100
100
}
101
101
102
+ unsafe async fn unsafe_async_fn ( x : u8 ) -> u8 {
103
+ await ! ( wake_and_yield_once( ) ) ;
104
+ x
105
+ }
106
+
107
+ struct Foo {
108
+ async fn async_method( x : u8 ) -> u8 {
109
+ unsafe {
110
+ await ! ( unsafe_async_fn( ) )
111
+ }
112
+ }
113
+ }
114
+
102
115
fn test_future_yields_once_then_returns < F , Fut > ( f : F )
103
116
where
104
117
F : FnOnce ( u8 ) -> Fut ,
You can’t perform that action at this time.
0 commit comments