@@ -1311,7 +1311,7 @@ pub struct Closure {
13111311 pub binder : ClosureBinder ,
13121312 pub capture_clause : CaptureBy ,
13131313 pub constness : Const ,
1314- pub coro_kind : CoroutineKind ,
1314+ pub coro_kind : Option < CoroutineKind > ,
13151315 pub movability : Movability ,
13161316 pub fn_decl : P < FnDecl > ,
13171317 pub body : P < Expr > ,
@@ -2417,8 +2417,6 @@ pub enum CoroutineKind {
24172417 Async { span : Span , closure_id : NodeId , return_impl_trait_id : NodeId } ,
24182418 /// `gen`, which evaluates to `impl Iterator`
24192419 Gen { span : Span , closure_id : NodeId , return_impl_trait_id : NodeId } ,
2420- /// Neither `async` nor `gen`
2421- None ,
24222420}
24232421
24242422impl CoroutineKind {
@@ -2430,14 +2428,12 @@ impl CoroutineKind {
24302428 matches ! ( self , CoroutineKind :: Gen { .. } )
24312429 }
24322430
2433- /// In this case this is an `async` return, the `NodeId` for the generated `impl Trait` item.
2434- pub fn opt_return_id ( self ) -> Option < ( NodeId , Span ) > {
2431+ /// In this case this is an `async` or `gen` return, the `NodeId` for the generated `impl Trait`
2432+ /// item.
2433+ pub fn return_id ( self ) -> ( NodeId , Span ) {
24352434 match self {
24362435 CoroutineKind :: Async { return_impl_trait_id, span, .. }
2437- | CoroutineKind :: Gen { return_impl_trait_id, span, .. } => {
2438- Some ( ( return_impl_trait_id, span) )
2439- }
2440- CoroutineKind :: None => None ,
2436+ | CoroutineKind :: Gen { return_impl_trait_id, span, .. } => ( return_impl_trait_id, span) ,
24412437 }
24422438 }
24432439}
@@ -2842,7 +2838,7 @@ pub struct FnHeader {
28422838 /// The `unsafe` keyword, if any
28432839 pub unsafety : Unsafe ,
28442840 /// Whether this is `async`, `gen`, or nothing.
2845- pub coro_kind : CoroutineKind ,
2841+ pub coro_kind : Option < CoroutineKind > ,
28462842 /// The `const` keyword, if any
28472843 pub constness : Const ,
28482844 /// The `extern` keyword and corresponding ABI string, if any
@@ -2854,20 +2850,15 @@ impl FnHeader {
28542850 pub fn has_qualifiers ( & self ) -> bool {
28552851 let Self { unsafety, coro_kind, constness, ext } = self ;
28562852 matches ! ( unsafety, Unsafe :: Yes ( _) )
2857- || ! matches ! ( coro_kind, CoroutineKind :: None )
2853+ || coro_kind. is_some ( )
28582854 || matches ! ( constness, Const :: Yes ( _) )
28592855 || !matches ! ( ext, Extern :: None )
28602856 }
28612857}
28622858
28632859impl Default for FnHeader {
28642860 fn default ( ) -> FnHeader {
2865- FnHeader {
2866- unsafety : Unsafe :: No ,
2867- coro_kind : CoroutineKind :: None ,
2868- constness : Const :: No ,
2869- ext : Extern :: None ,
2870- }
2861+ FnHeader { unsafety : Unsafe :: No , coro_kind : None , constness : Const :: No , ext : Extern :: None }
28712862 }
28722863}
28732864
0 commit comments