@@ -1296,7 +1296,7 @@ pub struct Closure {
12961296 pub binder : ClosureBinder ,
12971297 pub capture_clause : CaptureBy ,
12981298 pub constness : Const ,
1299- pub asyncness : Async ,
1299+ pub coro_kind : CoroutineKind ,
13001300 pub movability : Movability ,
13011301 pub fn_decl : P < FnDecl > ,
13021302 pub body : P < Expr > ,
@@ -2379,28 +2379,38 @@ pub enum Unsafe {
23792379 No ,
23802380}
23812381
2382+ /// Describes what kind of coroutine markers, if any, a function has.
2383+ ///
2384+ /// Coroutine markers are things that cause the function to generate a coroutine, such as `async`,
2385+ /// which makes the function return `impl Future`, or `gen`, which makes the function return `impl
2386+ /// Iterator`.
23822387#[ derive( Copy , Clone , Encodable , Decodable , Debug ) ]
2383- pub enum Async {
2384- Yes { span : Span , closure_id : NodeId , return_impl_trait_id : NodeId } ,
2385- No ,
2386- }
2387-
2388- #[ derive( Copy , Clone , Encodable , Decodable , Debug ) ]
2389- pub enum Gen {
2390- Yes { span : Span , closure_id : NodeId , return_impl_trait_id : NodeId } ,
2391- No ,
2388+ pub enum CoroutineKind {
2389+ /// `async`, which evaluates to `impl Future`
2390+ Async { span : Span , closure_id : NodeId , return_impl_trait_id : NodeId } ,
2391+ /// `gen`, which evaluates to `impl Iterator`
2392+ Gen { span : Span , closure_id : NodeId , return_impl_trait_id : NodeId } ,
2393+ /// Neither `async` nor `gen`
2394+ None ,
23922395}
23932396
2394- impl Async {
2397+ impl CoroutineKind {
23952398 pub fn is_async ( self ) -> bool {
2396- matches ! ( self , Async :: Yes { .. } )
2399+ matches ! ( self , CoroutineKind :: Async { .. } )
2400+ }
2401+
2402+ pub fn is_gen ( self ) -> bool {
2403+ matches ! ( self , CoroutineKind :: Gen { .. } )
23972404 }
23982405
23992406 /// In this case this is an `async` return, the `NodeId` for the generated `impl Trait` item.
24002407 pub fn opt_return_id ( self ) -> Option < ( NodeId , Span ) > {
24012408 match self {
2402- Async :: Yes { return_impl_trait_id, span, .. } => Some ( ( return_impl_trait_id, span) ) ,
2403- Async :: No => None ,
2409+ CoroutineKind :: Async { return_impl_trait_id, span, .. }
2410+ | CoroutineKind :: Gen { return_impl_trait_id, span, .. } => {
2411+ Some ( ( return_impl_trait_id, span) )
2412+ }
2413+ CoroutineKind :: None => None ,
24042414 }
24052415 }
24062416}
@@ -2804,36 +2814,32 @@ impl Extern {
28042814pub struct FnHeader {
28052815 /// The `unsafe` keyword, if any
28062816 pub unsafety : Unsafe ,
2807- /// The `async` keyword, if any
2808- pub asyncness : Async ,
2817+ /// Whether this is `async`, `gen`, or nothing.
2818+ pub coro_kind : CoroutineKind ,
28092819 /// The `const` keyword, if any
28102820 pub constness : Const ,
28112821 /// The `extern` keyword and corresponding ABI string, if any
28122822 pub ext : Extern ,
2813- /// The `gen` keyword, if any
2814- pub genness : Gen ,
28152823}
28162824
28172825impl FnHeader {
28182826 /// Does this function header have any qualifiers or is it empty?
28192827 pub fn has_qualifiers ( & self ) -> bool {
2820- let Self { unsafety, asyncness , constness, ext, genness } = self ;
2828+ let Self { unsafety, coro_kind , constness, ext } = self ;
28212829 matches ! ( unsafety, Unsafe :: Yes ( _) )
2822- || asyncness . is_async ( )
2830+ || ! matches ! ( coro_kind , CoroutineKind :: None )
28232831 || matches ! ( constness, Const :: Yes ( _) )
28242832 || !matches ! ( ext, Extern :: None )
2825- || matches ! ( genness, Gen :: Yes { .. } )
28262833 }
28272834}
28282835
28292836impl Default for FnHeader {
28302837 fn default ( ) -> FnHeader {
28312838 FnHeader {
28322839 unsafety : Unsafe :: No ,
2833- asyncness : Async :: No ,
2840+ coro_kind : CoroutineKind :: None ,
28342841 constness : Const :: No ,
28352842 ext : Extern :: None ,
2836- genness : Gen :: No ,
28372843 }
28382844 }
28392845}
@@ -3154,7 +3160,7 @@ mod size_asserts {
31543160 static_assert_size ! ( Block , 32 ) ;
31553161 static_assert_size ! ( Expr , 72 ) ;
31563162 static_assert_size ! ( ExprKind , 40 ) ;
3157- static_assert_size ! ( Fn , 168 ) ;
3163+ static_assert_size ! ( Fn , 160 ) ;
31583164 static_assert_size ! ( ForeignItem , 96 ) ;
31593165 static_assert_size ! ( ForeignItemKind , 24 ) ;
31603166 static_assert_size ! ( GenericArg , 24 ) ;
0 commit comments