@@ -1511,7 +1511,7 @@ impl<'hir> Body<'hir> {
1511
1511
#[ derive( HashStable_Generic , Encodable , Decodable ) ]
1512
1512
pub enum CoroutineKind {
1513
1513
/// An explicit `async` block or the body of an async function.
1514
- Async ( AsyncCoroutineKind ) ,
1514
+ Async ( CoroutineSource ) ,
1515
1515
1516
1516
/// A coroutine literal created via a `yield` inside a closure.
1517
1517
Coroutine ,
@@ -1520,56 +1520,45 @@ pub enum CoroutineKind {
1520
1520
impl fmt:: Display for CoroutineKind {
1521
1521
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1522
1522
match self {
1523
- CoroutineKind :: Async ( k) => fmt:: Display :: fmt ( k, f) ,
1523
+ CoroutineKind :: Async ( k) => {
1524
+ if f. alternate ( ) {
1525
+ f. write_str ( "`async` " ) ?;
1526
+ } else {
1527
+ f. write_str ( "async " ) ?
1528
+ }
1529
+ k. fmt ( f)
1530
+ }
1524
1531
CoroutineKind :: Coroutine => f. write_str ( "coroutine" ) ,
1525
1532
}
1526
1533
}
1527
1534
}
1528
1535
1529
- impl CoroutineKind {
1530
- pub fn descr ( & self ) -> & ' static str {
1531
- match self {
1532
- CoroutineKind :: Async ( ask) => ask. descr ( ) ,
1533
- CoroutineKind :: Coroutine => "coroutine" ,
1534
- }
1535
- }
1536
- }
1537
-
1538
- /// In the case of a coroutine created as part of an async construct,
1539
- /// which kind of async construct caused it to be created?
1536
+ /// In the case of a coroutine created as part of an async/gen construct,
1537
+ /// which kind of async/gen construct caused it to be created?
1540
1538
///
1541
1539
/// This helps error messages but is also used to drive coercions in
1542
1540
/// type-checking (see #60424).
1543
1541
#[ derive( Clone , PartialEq , Eq , Hash , Debug , Copy ) ]
1544
1542
#[ derive( HashStable_Generic , Encodable , Decodable ) ]
1545
- pub enum AsyncCoroutineKind {
1546
- /// An explicit `async` block written by the user.
1543
+ pub enum CoroutineSource {
1544
+ /// An explicit `async`/`gen` block written by the user.
1547
1545
Block ,
1548
1546
1549
- /// An explicit `async` closure written by the user.
1547
+ /// An explicit `async`/`gen` closure written by the user.
1550
1548
Closure ,
1551
1549
1552
- /// The `async` block generated as the body of an async function.
1550
+ /// The `async`/`gen` block generated as the body of an async/gen function.
1553
1551
Fn ,
1554
1552
}
1555
1553
1556
- impl fmt:: Display for AsyncCoroutineKind {
1554
+ impl fmt:: Display for CoroutineSource {
1557
1555
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1558
- f. write_str ( match self {
1559
- AsyncCoroutineKind :: Block => "async block" ,
1560
- AsyncCoroutineKind :: Closure => "async closure body" ,
1561
- AsyncCoroutineKind :: Fn => "async fn body" ,
1562
- } )
1563
- }
1564
- }
1565
-
1566
- impl AsyncCoroutineKind {
1567
- pub fn descr ( & self ) -> & ' static str {
1568
1556
match self {
1569
- AsyncCoroutineKind :: Block => "`async` block" ,
1570
- AsyncCoroutineKind :: Closure => "`async` closure body" ,
1571
- AsyncCoroutineKind :: Fn => "`async fn` body" ,
1557
+ CoroutineSource :: Block => "block" ,
1558
+ CoroutineSource :: Closure => "closure body" ,
1559
+ CoroutineSource :: Fn => "fn body" ,
1572
1560
}
1561
+ . fmt ( f)
1573
1562
}
1574
1563
}
1575
1564
0 commit comments