@@ -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 > ,
@@ -2405,8 +2405,6 @@ pub enum CoroutineKind {
24052405 Async { span : Span , closure_id : NodeId , return_impl_trait_id : NodeId } ,
24062406 /// `gen`, which evaluates to `impl Iterator`
24072407 Gen { span : Span , closure_id : NodeId , return_impl_trait_id : NodeId } ,
2408- /// Neither `async` nor `gen`
2409- None ,
24102408}
24112409
24122410impl CoroutineKind {
@@ -2418,14 +2416,12 @@ impl CoroutineKind {
24182416 matches ! ( self , CoroutineKind :: Gen { .. } )
24192417 }
24202418
2421- /// In this case this is an `async` return, the `NodeId` for the generated `impl Trait` item.
2422- pub fn opt_return_id ( self ) -> Option < ( NodeId , Span ) > {
2419+ /// In this case this is an `async` or `gen` return, the `NodeId` for the generated `impl Trait`
2420+ /// item.
2421+ pub fn return_id ( self ) -> ( NodeId , Span ) {
24232422 match self {
24242423 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 ,
2424+ | CoroutineKind :: Gen { return_impl_trait_id, span, .. } => ( return_impl_trait_id, span) ,
24292425 }
24302426 }
24312427}
@@ -2830,7 +2826,7 @@ pub struct FnHeader {
28302826 /// The `unsafe` keyword, if any
28312827 pub unsafety : Unsafe ,
28322828 /// Whether this is `async`, `gen`, or nothing.
2833- pub coro_kind : CoroutineKind ,
2829+ pub coro_kind : Option < CoroutineKind > ,
28342830 /// The `const` keyword, if any
28352831 pub constness : Const ,
28362832 /// The `extern` keyword and corresponding ABI string, if any
@@ -2842,20 +2838,15 @@ impl FnHeader {
28422838 pub fn has_qualifiers ( & self ) -> bool {
28432839 let Self { unsafety, coro_kind, constness, ext } = self ;
28442840 matches ! ( unsafety, Unsafe :: Yes ( _) )
2845- || ! matches ! ( coro_kind, CoroutineKind :: None )
2841+ || coro_kind. is_some ( )
28462842 || matches ! ( constness, Const :: Yes ( _) )
28472843 || !matches ! ( ext, Extern :: None )
28482844 }
28492845}
28502846
28512847impl Default for FnHeader {
28522848 fn default ( ) -> FnHeader {
2853- FnHeader {
2854- unsafety : Unsafe :: No ,
2855- coro_kind : CoroutineKind :: None ,
2856- constness : Const :: No ,
2857- ext : Extern :: None ,
2858- }
2849+ FnHeader { unsafety : Unsafe :: No , coro_kind : None , constness : Const :: No , ext : Extern :: None }
28592850 }
28602851}
28612852
0 commit comments