@@ -1311,7 +1311,7 @@ pub struct Closure {
1311
1311
pub binder : ClosureBinder ,
1312
1312
pub capture_clause : CaptureBy ,
1313
1313
pub constness : Const ,
1314
- pub coro_kind : CoroutineKind ,
1314
+ pub coro_kind : Option < CoroutineKind > ,
1315
1315
pub movability : Movability ,
1316
1316
pub fn_decl : P < FnDecl > ,
1317
1317
pub body : P < Expr > ,
@@ -2405,8 +2405,6 @@ pub enum CoroutineKind {
2405
2405
Async { span : Span , closure_id : NodeId , return_impl_trait_id : NodeId } ,
2406
2406
/// `gen`, which evaluates to `impl Iterator`
2407
2407
Gen { span : Span , closure_id : NodeId , return_impl_trait_id : NodeId } ,
2408
- /// Neither `async` nor `gen`
2409
- None ,
2410
2408
}
2411
2409
2412
2410
impl CoroutineKind {
@@ -2418,14 +2416,12 @@ impl CoroutineKind {
2418
2416
matches ! ( self , CoroutineKind :: Gen { .. } )
2419
2417
}
2420
2418
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 ) {
2423
2422
match self {
2424
2423
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) ,
2429
2425
}
2430
2426
}
2431
2427
}
@@ -2830,7 +2826,7 @@ pub struct FnHeader {
2830
2826
/// The `unsafe` keyword, if any
2831
2827
pub unsafety : Unsafe ,
2832
2828
/// Whether this is `async`, `gen`, or nothing.
2833
- pub coro_kind : CoroutineKind ,
2829
+ pub coro_kind : Option < CoroutineKind > ,
2834
2830
/// The `const` keyword, if any
2835
2831
pub constness : Const ,
2836
2832
/// The `extern` keyword and corresponding ABI string, if any
@@ -2842,20 +2838,15 @@ impl FnHeader {
2842
2838
pub fn has_qualifiers ( & self ) -> bool {
2843
2839
let Self { unsafety, coro_kind, constness, ext } = self ;
2844
2840
matches ! ( unsafety, Unsafe :: Yes ( _) )
2845
- || ! matches ! ( coro_kind, CoroutineKind :: None )
2841
+ || coro_kind. is_some ( )
2846
2842
|| matches ! ( constness, Const :: Yes ( _) )
2847
2843
|| !matches ! ( ext, Extern :: None )
2848
2844
}
2849
2845
}
2850
2846
2851
2847
impl Default for FnHeader {
2852
2848
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 }
2859
2850
}
2860
2851
}
2861
2852
0 commit comments