@@ -501,10 +501,13 @@ enum Inner {
501
501
} ,
502
502
Fn {
503
503
is_variadic : bool ,
504
+ no_escape : bool ,
504
505
arguments : Vec < Inner > ,
505
506
result_type : Box < Inner > ,
506
507
} ,
507
508
Block {
509
+ sendable : Option < bool > ,
510
+ no_escape : bool ,
508
511
arguments : Vec < Inner > ,
509
512
result_type : Box < Inner > ,
510
513
} ,
@@ -546,7 +549,7 @@ impl Inner {
546
549
547
550
match attr {
548
551
Some ( UnexposedAttr :: NonIsolated | UnexposedAttr :: UIActor ) => {
549
- // Ignored for now; these are almost always also emitted on the method/property,
552
+ // Ignored for now; these are usually also emitted on the method/property,
550
553
// which is where they will be useful in any case.
551
554
}
552
555
Some ( attr) => error ! ( ?attr, "unknown attribute" ) ,
@@ -681,12 +684,15 @@ impl Inner {
681
684
match Self :: parse ( ty, Lifetime :: Unspecified , context) {
682
685
Self :: Fn {
683
686
is_variadic : false ,
687
+ no_escape,
684
688
arguments,
685
689
result_type,
686
690
} => Self :: Pointer {
687
691
nullability,
688
692
is_const,
689
693
pointee : Box :: new ( Self :: Block {
694
+ sendable : None ,
695
+ no_escape,
690
696
arguments,
691
697
result_type,
692
698
} ) ,
@@ -924,6 +930,7 @@ impl Inner {
924
930
925
931
Self :: Fn {
926
932
is_variadic : ty. is_variadic ( ) ,
933
+ no_escape : false ,
927
934
arguments,
928
935
result_type : Box :: new ( result_type) ,
929
936
}
@@ -1008,11 +1015,14 @@ impl Inner {
1008
1015
//
1009
1016
// }
1010
1017
Self :: Fn {
1018
+ is_variadic : _,
1019
+ no_escape : _,
1011
1020
arguments,
1012
1021
result_type,
1013
- ..
1014
1022
}
1015
1023
| Self :: Block {
1024
+ sendable : _,
1025
+ no_escape : _,
1016
1026
arguments,
1017
1027
result_type,
1018
1028
} => {
@@ -1106,6 +1116,7 @@ impl fmt::Display for Inner {
1106
1116
} => match & * * pointee {
1107
1117
Self :: Fn {
1108
1118
is_variadic,
1119
+ no_escape : _,
1109
1120
arguments,
1110
1121
result_type,
1111
1122
} => {
@@ -1161,6 +1172,8 @@ impl fmt::Display for Inner {
1161
1172
Enum { id } | Struct { id } | TypeDef { id } => write ! ( f, "{}" , id. path( ) ) ,
1162
1173
Self :: Fn { .. } => write ! ( f, "TodoFunction" ) ,
1163
1174
Self :: Block {
1175
+ sendable : _,
1176
+ no_escape : _,
1164
1177
arguments,
1165
1178
result_type,
1166
1179
} => {
@@ -1213,10 +1226,44 @@ impl Ty {
1213
1226
pub fn parse_method_argument (
1214
1227
ty : Type < ' _ > ,
1215
1228
_qualifier : Option < MethodArgumentQualifier > ,
1216
- _sendable : Option < bool > ,
1229
+ mut arg_sendable : Option < bool > ,
1230
+ mut arg_no_escape : bool ,
1217
1231
context : & Context < ' _ > ,
1218
1232
) -> Self {
1219
- let ty = Inner :: parse ( ty, Lifetime :: Unspecified , context) ;
1233
+ let mut ty = Inner :: parse ( ty, Lifetime :: Unspecified , context) ;
1234
+
1235
+ match & mut ty {
1236
+ Inner :: Pointer { pointee, .. } => match & mut * * pointee {
1237
+ Inner :: Block {
1238
+ sendable,
1239
+ no_escape,
1240
+ ..
1241
+ } => {
1242
+ * sendable = arg_sendable;
1243
+ * no_escape = arg_no_escape;
1244
+ arg_sendable = None ;
1245
+ arg_no_escape = false ;
1246
+ }
1247
+ Inner :: Fn { no_escape, .. } => {
1248
+ * no_escape = arg_no_escape;
1249
+ arg_no_escape = false ;
1250
+ }
1251
+ _ => { }
1252
+ } ,
1253
+ // Ignore NSComparator for now
1254
+ Inner :: TypeDef { id } if id. is_nscomparator ( ) => {
1255
+ arg_no_escape = false ;
1256
+ }
1257
+ _ => { }
1258
+ }
1259
+
1260
+ if arg_sendable. is_some ( ) {
1261
+ warn ! ( ?ty, "did not consume sendable in argument" ) ;
1262
+ }
1263
+
1264
+ if arg_no_escape {
1265
+ warn ! ( ?ty, "did not consume no_escape in argument" ) ;
1266
+ }
1220
1267
1221
1268
match & ty {
1222
1269
Inner :: Pointer { pointee, .. } => pointee. visit_lifetime ( |lifetime| {
@@ -1274,7 +1321,7 @@ impl Ty {
1274
1321
}
1275
1322
1276
1323
pub fn parse_function_argument ( ty : Type < ' _ > , context : & Context < ' _ > ) -> Self {
1277
- let mut this = Self :: parse_method_argument ( ty, None , None , context) ;
1324
+ let mut this = Self :: parse_method_argument ( ty, None , None , false , context) ;
1278
1325
this. kind = TyKind :: FnArgument ;
1279
1326
this
1280
1327
}
0 commit comments