@@ -532,10 +532,30 @@ impl Inner {
532
532
533
533
let unexposed_nullability = if let TypeKind :: Unexposed = ty. get_kind ( ) {
534
534
let nullability = ty. get_nullability ( ) ;
535
- attributed_name = parse_unexposed_tokens ( & attributed_name) ;
535
+ let ( new_attributed_name , attributed_attr ) = parse_unexposed_tokens ( & attributed_name) ;
536
536
// Also parse the expected name to ensure that the formatting that
537
537
// TokenStream does is the same on both.
538
- name = parse_unexposed_tokens ( & name) ;
538
+ let ( new_name, attr) = parse_unexposed_tokens ( & name) ;
539
+ if attributed_attr != attr {
540
+ error ! (
541
+ ?attributed_attr,
542
+ ?attr,
543
+ "attributed attr was not equal to attr" ,
544
+ ) ;
545
+ }
546
+
547
+ match attr {
548
+ Some ( UnexposedAttr :: NonIsolated | UnexposedAttr :: UIActor ) => {
549
+ // Ignored for now; these are almost always also emitted on the method/property,
550
+ // which is where they will be useful in any case.
551
+ }
552
+ Some ( attr) => error ! ( ?attr, "unknown attribute" ) ,
553
+ None => { }
554
+ }
555
+
556
+ attributed_name = new_attributed_name;
557
+ name = new_name;
558
+
539
559
ty = ty
540
560
. get_modified_type ( )
541
561
. expect ( "attributed type to have modified type" ) ;
@@ -1193,6 +1213,7 @@ impl Ty {
1193
1213
pub fn parse_method_argument (
1194
1214
ty : Type < ' _ > ,
1195
1215
_qualifier : Option < MethodArgumentQualifier > ,
1216
+ _sendable : Option < bool > ,
1196
1217
context : & Context < ' _ > ,
1197
1218
) -> Self {
1198
1219
let ty = Inner :: parse ( ty, Lifetime :: Unspecified , context) ;
@@ -1253,7 +1274,7 @@ impl Ty {
1253
1274
}
1254
1275
1255
1276
pub fn parse_function_argument ( ty : Type < ' _ > , context : & Context < ' _ > ) -> Self {
1256
- let mut this = Self :: parse_method_argument ( ty, None , context) ;
1277
+ let mut this = Self :: parse_method_argument ( ty, None , None , context) ;
1257
1278
this. kind = TyKind :: FnArgument ;
1258
1279
this
1259
1280
}
@@ -1304,6 +1325,7 @@ impl Ty {
1304
1325
ty : Type < ' _ > ,
1305
1326
// Ignored; see `parse_property_return`
1306
1327
_is_copy : bool ,
1328
+ _sendable : Option < bool > ,
1307
1329
context : & Context < ' _ > ,
1308
1330
) -> Self {
1309
1331
let ty = Inner :: parse ( ty, Lifetime :: Unspecified , context) ;
@@ -1320,7 +1342,12 @@ impl Ty {
1320
1342
}
1321
1343
}
1322
1344
1323
- pub fn parse_property_return ( ty : Type < ' _ > , is_copy : bool , context : & Context < ' _ > ) -> Self {
1345
+ pub fn parse_property_return (
1346
+ ty : Type < ' _ > ,
1347
+ is_copy : bool ,
1348
+ _sendable : Option < bool > ,
1349
+ context : & Context < ' _ > ,
1350
+ ) -> Self {
1324
1351
let mut ty = Inner :: parse ( ty, Lifetime :: Unspecified , context) ;
1325
1352
1326
1353
// `@property(copy)` is expected to always return a nonnull instance
@@ -1736,10 +1763,10 @@ impl fmt::Display for Ty {
1736
1763
/// - NS_SWIFT_UNAVAILABLE
1737
1764
/// - NS_REFINED_FOR_SWIFT
1738
1765
/// - ...
1739
- fn parse_unexposed_tokens ( s : & str ) -> String {
1766
+ fn parse_unexposed_tokens ( s : & str ) -> ( String , Option < UnexposedAttr > ) {
1740
1767
let tokens = TokenStream :: from_str ( s) . expect ( "parse attributed name" ) ;
1741
1768
let mut iter = tokens. into_iter ( ) . peekable ( ) ;
1742
- if let Some ( TokenTree :: Ident ( ident) ) = iter. peek ( ) {
1769
+ let attr = if let Some ( TokenTree :: Ident ( ident) ) = iter. peek ( ) {
1743
1770
let ident = ident. to_string ( ) ;
1744
1771
if let Ok ( attr) = UnexposedAttr :: from_name ( & ident, || {
1745
1772
iter. next ( ) ;
@@ -1750,13 +1777,15 @@ fn parse_unexposed_tokens(s: &str) -> String {
1750
1777
None
1751
1778
}
1752
1779
} ) {
1753
- if let Some ( attr) = attr {
1754
- error ! ( ?attr, "unknown attribute" ) ;
1755
- }
1756
1780
iter. next ( ) ;
1781
+ attr
1782
+ } else {
1783
+ None
1757
1784
}
1758
- }
1759
- TokenStream :: from_iter ( iter) . to_string ( )
1785
+ } else {
1786
+ None
1787
+ } ;
1788
+ ( TokenStream :: from_iter ( iter) . to_string ( ) , attr)
1760
1789
}
1761
1790
1762
1791
#[ cfg( test) ]
@@ -1766,7 +1795,9 @@ mod tests {
1766
1795
#[ test]
1767
1796
fn test_parse_unexposed_tokens ( ) {
1768
1797
fn check ( inp : & str , expected : & str ) {
1769
- assert_eq ! ( parse_unexposed_tokens( inp) , expected) ;
1798
+ let ( actual, attr) = parse_unexposed_tokens ( inp) ;
1799
+ assert_eq ! ( actual, expected) ;
1800
+ assert_eq ! ( attr, None ) ;
1770
1801
}
1771
1802
1772
1803
check ( "NS_RETURNS_INNER_POINTER const char *" , "const char *" ) ;
@@ -1791,5 +1822,13 @@ mod tests {
1791
1822
"API_DEPRECATED_WITH_REPLACEMENT(\" @\\ \" com.adobe.encapsulated-postscript\\ \" \" , macos(10.0,10.14)) NSPasteboardType __strong" ,
1792
1823
"NSPasteboardType __strong" ,
1793
1824
) ;
1825
+
1826
+ let ( actual, attr) = parse_unexposed_tokens ( "NS_SWIFT_NONISOLATED NSTextAttachment *" ) ;
1827
+ assert_eq ! ( actual, "NSTextAttachment *" ) ;
1828
+ assert_eq ! ( attr, Some ( UnexposedAttr :: NonIsolated ) ) ;
1829
+
1830
+ let ( actual, attr) = parse_unexposed_tokens ( "NS_SWIFT_UI_ACTOR SEL" ) ;
1831
+ assert_eq ! ( actual, "SEL" ) ;
1832
+ assert_eq ! ( attr, Some ( UnexposedAttr :: UIActor ) ) ;
1794
1833
}
1795
1834
}
0 commit comments