@@ -872,7 +872,8 @@ fn should_encode_span(def_kind: DefKind) -> bool {
872
872
| DefKind :: OpaqueTy
873
873
| DefKind :: Field
874
874
| DefKind :: Impl { .. }
875
- | DefKind :: Closure => true ,
875
+ | DefKind :: Closure
876
+ | DefKind :: SyntheticCoroutineBody => true ,
876
877
DefKind :: ForeignMod | DefKind :: GlobalAsm => false ,
877
878
}
878
879
}
@@ -902,6 +903,7 @@ fn should_encode_attrs(def_kind: DefKind) -> bool {
902
903
// https://github.com/model-checking/kani and is not a performance
903
904
// or maintenance issue for us.
904
905
DefKind :: Closure => true ,
906
+ DefKind :: SyntheticCoroutineBody => false ,
905
907
DefKind :: TyParam
906
908
| DefKind :: ConstParam
907
909
| DefKind :: Ctor ( ..)
@@ -948,7 +950,8 @@ fn should_encode_expn_that_defined(def_kind: DefKind) -> bool {
948
950
| DefKind :: Field
949
951
| DefKind :: LifetimeParam
950
952
| DefKind :: GlobalAsm
951
- | DefKind :: Closure => false ,
953
+ | DefKind :: Closure
954
+ | DefKind :: SyntheticCoroutineBody => false ,
952
955
}
953
956
}
954
957
@@ -984,7 +987,8 @@ fn should_encode_visibility(def_kind: DefKind) -> bool {
984
987
| DefKind :: GlobalAsm
985
988
| DefKind :: Impl { .. }
986
989
| DefKind :: Closure
987
- | DefKind :: ExternCrate => false ,
990
+ | DefKind :: ExternCrate
991
+ | DefKind :: SyntheticCoroutineBody => false ,
988
992
}
989
993
}
990
994
@@ -1019,7 +1023,8 @@ fn should_encode_stability(def_kind: DefKind) -> bool {
1019
1023
| DefKind :: InlineConst
1020
1024
| DefKind :: GlobalAsm
1021
1025
| DefKind :: Closure
1022
- | DefKind :: ExternCrate => false ,
1026
+ | DefKind :: ExternCrate
1027
+ | DefKind :: SyntheticCoroutineBody => false ,
1023
1028
}
1024
1029
}
1025
1030
@@ -1061,6 +1066,8 @@ fn should_encode_mir(
1061
1066
}
1062
1067
// Coroutines require optimized MIR to compute layout.
1063
1068
DefKind :: Closure if tcx. is_coroutine ( def_id. to_def_id ( ) ) => ( false , true ) ,
1069
+ // FIXME: lol
1070
+ DefKind :: SyntheticCoroutineBody => ( false , true ) ,
1064
1071
// Full-fledged functions + closures
1065
1072
DefKind :: AssocFn | DefKind :: Fn | DefKind :: Closure => {
1066
1073
let generics = tcx. generics_of ( def_id) ;
@@ -1109,7 +1116,8 @@ fn should_encode_variances<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, def_kind: Def
1109
1116
| DefKind :: InlineConst
1110
1117
| DefKind :: GlobalAsm
1111
1118
| DefKind :: Closure
1112
- | DefKind :: ExternCrate => false ,
1119
+ | DefKind :: ExternCrate
1120
+ | DefKind :: SyntheticCoroutineBody => false ,
1113
1121
DefKind :: TyAlias => tcx. type_alias_is_lazy ( def_id) ,
1114
1122
}
1115
1123
}
@@ -1137,7 +1145,8 @@ fn should_encode_generics(def_kind: DefKind) -> bool {
1137
1145
| DefKind :: Impl { .. }
1138
1146
| DefKind :: Field
1139
1147
| DefKind :: TyParam
1140
- | DefKind :: Closure => true ,
1148
+ | DefKind :: Closure
1149
+ | DefKind :: SyntheticCoroutineBody => true ,
1141
1150
DefKind :: Mod
1142
1151
| DefKind :: ForeignMod
1143
1152
| DefKind :: ConstParam
@@ -1168,7 +1177,8 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
1168
1177
| DefKind :: Closure
1169
1178
| DefKind :: ConstParam
1170
1179
| DefKind :: AnonConst
1171
- | DefKind :: InlineConst => true ,
1180
+ | DefKind :: InlineConst
1181
+ | DefKind :: SyntheticCoroutineBody => true ,
1172
1182
1173
1183
DefKind :: OpaqueTy => {
1174
1184
let origin = tcx. opaque_type_origin ( def_id) ;
@@ -1240,7 +1250,8 @@ fn should_encode_fn_sig(def_kind: DefKind) -> bool {
1240
1250
| DefKind :: Use
1241
1251
| DefKind :: LifetimeParam
1242
1252
| DefKind :: GlobalAsm
1243
- | DefKind :: ExternCrate => false ,
1253
+ | DefKind :: ExternCrate
1254
+ | DefKind :: SyntheticCoroutineBody => false ,
1244
1255
}
1245
1256
}
1246
1257
@@ -1277,7 +1288,8 @@ fn should_encode_constness(def_kind: DefKind) -> bool {
1277
1288
| DefKind :: Use
1278
1289
| DefKind :: LifetimeParam
1279
1290
| DefKind :: GlobalAsm
1280
- | DefKind :: ExternCrate => false ,
1291
+ | DefKind :: ExternCrate
1292
+ | DefKind :: SyntheticCoroutineBody => false ,
1281
1293
}
1282
1294
}
1283
1295
@@ -1310,7 +1322,8 @@ fn should_encode_const(def_kind: DefKind) -> bool {
1310
1322
| DefKind :: Use
1311
1323
| DefKind :: LifetimeParam
1312
1324
| DefKind :: GlobalAsm
1313
- | DefKind :: ExternCrate => false ,
1325
+ | DefKind :: ExternCrate
1326
+ | DefKind :: SyntheticCoroutineBody => false ,
1314
1327
}
1315
1328
}
1316
1329
@@ -1366,6 +1379,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1366
1379
let def_span = tcx. def_span ( local_id) ;
1367
1380
record ! ( self . tables. def_span[ def_id] <- def_span) ;
1368
1381
}
1382
+ // FIXME(async_closures): We should just use `tcx.attrs` rather than going
1383
+ // through the HIR. Historically, though, this has been inefficient apparently.
1384
+ // For now, it's kind of pointless to fix, because coroutine-closures' coroutine
1385
+ // bodies have no attrs anyways.
1369
1386
if should_encode_attrs ( def_kind) {
1370
1387
self . encode_attrs ( local_id) ;
1371
1388
}
@@ -1458,7 +1475,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1458
1475
record ! ( self . tables. associated_type_for_effects[ def_id] <- assoc_def_id) ;
1459
1476
}
1460
1477
}
1461
- if def_kind == DefKind :: Closure
1478
+ if let DefKind :: Closure | DefKind :: SyntheticCoroutineBody = def_kind
1462
1479
&& let Some ( coroutine_kind) = self . tcx . coroutine_kind ( def_id)
1463
1480
{
1464
1481
self . tables . coroutine_kind . set ( def_id. index , Some ( coroutine_kind) )
0 commit comments