@@ -1319,7 +1319,7 @@ impl fmt::Display for Stmt {
1319
1319
derives,
1320
1320
mutability,
1321
1321
skipped,
1322
- sendable : _ ,
1322
+ sendable,
1323
1323
mainthreadonly : _,
1324
1324
} => {
1325
1325
if * skipped {
@@ -1429,6 +1429,20 @@ impl fmt::Display for Stmt {
1429
1429
}
1430
1430
writeln ! ( f, " }}" ) ?;
1431
1431
writeln ! ( f, ");" ) ?;
1432
+
1433
+ if * sendable && generics. is_empty ( ) {
1434
+ writeln ! ( f) ?;
1435
+ if let Some ( feature) = & main_feature_gate {
1436
+ writeln ! ( f, " #[cfg(feature = \" {feature}\" )]" ) ?;
1437
+ }
1438
+ writeln ! ( f, "unsafe impl Send for {} {{}}" , id. name) ?;
1439
+
1440
+ writeln ! ( f) ?;
1441
+ if let Some ( feature) = & main_feature_gate {
1442
+ writeln ! ( f, " #[cfg(feature = \" {feature}\" )]" ) ?;
1443
+ }
1444
+ writeln ! ( f, "unsafe impl Sync for {} {{}}" , id. name) ?;
1445
+ }
1432
1446
}
1433
1447
Self :: Methods {
1434
1448
cls,
@@ -1608,6 +1622,15 @@ impl fmt::Display for Stmt {
1608
1622
write ! ( f, "{}" , protocol. path( ) ) ?;
1609
1623
}
1610
1624
}
1625
+ // TODO
1626
+ // if *required_sendable {
1627
+ // if protocols.is_empty() {
1628
+ // write!(f, ": ")?;
1629
+ // } else {
1630
+ // write!(f, "+ ")?;
1631
+ // }
1632
+ // write!(f, "Send + Sync")?;
1633
+ // }
1611
1634
writeln ! ( f, " {{" ) ?;
1612
1635
1613
1636
for method in methods {
@@ -1649,7 +1672,7 @@ impl fmt::Display for Stmt {
1649
1672
availability,
1650
1673
boxable : _,
1651
1674
fields,
1652
- sendable : _ ,
1675
+ sendable,
1653
1676
} => {
1654
1677
writeln ! ( f, "extern_struct!(" ) ?;
1655
1678
if let Some ( encoding_name) = encoding_name {
@@ -1667,14 +1690,22 @@ impl fmt::Display for Stmt {
1667
1690
}
1668
1691
writeln ! ( f, " }}" ) ?;
1669
1692
writeln ! ( f, ");" ) ?;
1693
+
1694
+ if let Some ( true ) = sendable {
1695
+ writeln ! ( f) ?;
1696
+ writeln ! ( f, "unsafe impl Send for {} {{}}" , id. name) ?;
1697
+
1698
+ writeln ! ( f) ?;
1699
+ writeln ! ( f, "unsafe impl Sync for {} {{}}" , id. name) ?;
1700
+ }
1670
1701
}
1671
1702
Self :: EnumDecl {
1672
1703
id,
1673
1704
availability,
1674
1705
ty,
1675
1706
kind,
1676
1707
variants,
1677
- sendable : _ ,
1708
+ sendable,
1678
1709
} => {
1679
1710
let macro_name = match kind {
1680
1711
None => "extern_enum" ,
@@ -1698,6 +1729,16 @@ impl fmt::Display for Stmt {
1698
1729
}
1699
1730
writeln ! ( f, " }}" ) ?;
1700
1731
writeln ! ( f, ");" ) ?;
1732
+
1733
+ if let Some ( true ) = sendable {
1734
+ if let Some ( name) = & id. name {
1735
+ writeln ! ( f) ?;
1736
+ writeln ! ( f, "unsafe impl Send for {name} {{}}" ) ?;
1737
+
1738
+ writeln ! ( f) ?;
1739
+ writeln ! ( f, "unsafe impl Sync for {name} {{}}" ) ?;
1740
+ }
1741
+ }
1701
1742
}
1702
1743
Self :: VarDecl {
1703
1744
id,
0 commit comments