@@ -1311,7 +1311,7 @@ pub struct Closure {
13111311 pub binder : ClosureBinder ,
13121312 pub capture_clause : CaptureBy ,
13131313 pub constness : Const ,
1314- pub asyncness : Async ,
1314+ pub coro_kind : CoroutineKind ,
13151315 pub movability : Movability ,
13161316 pub fn_decl : P < FnDecl > ,
13171317 pub body : P < Expr > ,
@@ -2394,28 +2394,38 @@ pub enum Unsafe {
23942394 No ,
23952395}
23962396
2397+ /// Describes what kind of coroutine markers, if any, a function has.
2398+ ///
2399+ /// Coroutine markers are things that cause the function to generate a coroutine, such as `async`,
2400+ /// which makes the function return `impl Future`, or `gen`, which makes the function return `impl
2401+ /// Iterator`.
23972402#[ derive( Copy , Clone , Encodable , Decodable , Debug ) ]
2398- pub enum Async {
2399- Yes { span : Span , closure_id : NodeId , return_impl_trait_id : NodeId } ,
2400- No ,
2401- }
2402-
2403- #[ derive( Copy , Clone , Encodable , Decodable , Debug ) ]
2404- pub enum Gen {
2405- Yes { span : Span , closure_id : NodeId , return_impl_trait_id : NodeId } ,
2406- No ,
2403+ pub enum CoroutineKind {
2404+ /// `async`, which evaluates to `impl Future`
2405+ Async { span : Span , closure_id : NodeId , return_impl_trait_id : NodeId } ,
2406+ /// `gen`, which evaluates to `impl Iterator`
2407+ Gen { span : Span , closure_id : NodeId , return_impl_trait_id : NodeId } ,
2408+ /// Neither `async` nor `gen`
2409+ None ,
24072410}
24082411
2409- impl Async {
2412+ impl CoroutineKind {
24102413 pub fn is_async ( self ) -> bool {
2411- matches ! ( self , Async :: Yes { .. } )
2414+ matches ! ( self , CoroutineKind :: Async { .. } )
2415+ }
2416+
2417+ pub fn is_gen ( self ) -> bool {
2418+ matches ! ( self , CoroutineKind :: Gen { .. } )
24122419 }
24132420
24142421 /// In this case this is an `async` return, the `NodeId` for the generated `impl Trait` item.
24152422 pub fn opt_return_id ( self ) -> Option < ( NodeId , Span ) > {
24162423 match self {
2417- Async :: Yes { return_impl_trait_id, span, .. } => Some ( ( return_impl_trait_id, span) ) ,
2418- Async :: No => None ,
2424+ CoroutineKind :: Async { return_impl_trait_id, span, .. }
2425+ | CoroutineKind :: Gen { return_impl_trait_id, span, .. } => {
2426+ Some ( ( return_impl_trait_id, span) )
2427+ }
2428+ CoroutineKind :: None => None ,
24192429 }
24202430 }
24212431}
@@ -2819,36 +2829,32 @@ impl Extern {
28192829pub struct FnHeader {
28202830 /// The `unsafe` keyword, if any
28212831 pub unsafety : Unsafe ,
2822- /// The `async` keyword, if any
2823- pub asyncness : Async ,
2832+ /// Whether this is `async`, `gen`, or nothing.
2833+ pub coro_kind : CoroutineKind ,
28242834 /// The `const` keyword, if any
28252835 pub constness : Const ,
28262836 /// The `extern` keyword and corresponding ABI string, if any
28272837 pub ext : Extern ,
2828- /// The `gen` keyword, if any
2829- pub genness : Gen ,
28302838}
28312839
28322840impl FnHeader {
28332841 /// Does this function header have any qualifiers or is it empty?
28342842 pub fn has_qualifiers ( & self ) -> bool {
2835- let Self { unsafety, asyncness , constness, ext, genness } = self ;
2843+ let Self { unsafety, coro_kind , constness, ext } = self ;
28362844 matches ! ( unsafety, Unsafe :: Yes ( _) )
2837- || asyncness . is_async ( )
2845+ || ! matches ! ( coro_kind , CoroutineKind :: None )
28382846 || matches ! ( constness, Const :: Yes ( _) )
28392847 || !matches ! ( ext, Extern :: None )
2840- || matches ! ( genness, Gen :: Yes { .. } )
28412848 }
28422849}
28432850
28442851impl Default for FnHeader {
28452852 fn default ( ) -> FnHeader {
28462853 FnHeader {
28472854 unsafety : Unsafe :: No ,
2848- asyncness : Async :: No ,
2855+ coro_kind : CoroutineKind :: None ,
28492856 constness : Const :: No ,
28502857 ext : Extern :: None ,
2851- genness : Gen :: No ,
28522858 }
28532859 }
28542860}
@@ -3169,7 +3175,7 @@ mod size_asserts {
31693175 static_assert_size ! ( Block , 32 ) ;
31703176 static_assert_size ! ( Expr , 72 ) ;
31713177 static_assert_size ! ( ExprKind , 40 ) ;
3172- static_assert_size ! ( Fn , 168 ) ;
3178+ static_assert_size ! ( Fn , 160 ) ;
31733179 static_assert_size ! ( ForeignItem , 96 ) ;
31743180 static_assert_size ! ( ForeignItemKind , 24 ) ;
31753181 static_assert_size ! ( GenericArg , 24 ) ;
0 commit comments