@@ -857,7 +857,8 @@ fn should_encode_span(def_kind: DefKind) -> bool {
857
857
| DefKind :: OpaqueTy
858
858
| DefKind :: Field
859
859
| DefKind :: Impl { .. }
860
- | DefKind :: Closure => true ,
860
+ | DefKind :: Closure
861
+ | DefKind :: Coroutine => true ,
861
862
DefKind :: ForeignMod | DefKind :: GlobalAsm => false ,
862
863
}
863
864
}
@@ -897,7 +898,8 @@ fn should_encode_attrs(def_kind: DefKind) -> bool {
897
898
| DefKind :: InlineConst
898
899
| DefKind :: OpaqueTy
899
900
| DefKind :: LifetimeParam
900
- | DefKind :: GlobalAsm => false ,
901
+ | DefKind :: GlobalAsm
902
+ | DefKind :: Coroutine => false ,
901
903
}
902
904
}
903
905
@@ -932,7 +934,8 @@ fn should_encode_expn_that_defined(def_kind: DefKind) -> bool {
932
934
| DefKind :: Field
933
935
| DefKind :: LifetimeParam
934
936
| DefKind :: GlobalAsm
935
- | DefKind :: Closure => false ,
937
+ | DefKind :: Closure
938
+ | DefKind :: Coroutine => false ,
936
939
}
937
940
}
938
941
@@ -967,6 +970,7 @@ fn should_encode_visibility(def_kind: DefKind) -> bool {
967
970
| DefKind :: GlobalAsm
968
971
| DefKind :: Impl { .. }
969
972
| DefKind :: Closure
973
+ | DefKind :: Coroutine
970
974
| DefKind :: ExternCrate => false ,
971
975
}
972
976
}
@@ -1002,6 +1006,7 @@ fn should_encode_stability(def_kind: DefKind) -> bool {
1002
1006
| DefKind :: InlineConst
1003
1007
| DefKind :: GlobalAsm
1004
1008
| DefKind :: Closure
1009
+ | DefKind :: Coroutine
1005
1010
| DefKind :: ExternCrate => false ,
1006
1011
}
1007
1012
}
@@ -1044,8 +1049,6 @@ fn should_encode_mir(
1044
1049
| DefKind :: AssocConst
1045
1050
| DefKind :: Static ( ..)
1046
1051
| DefKind :: Const => ( true , false ) ,
1047
- // Coroutines require optimized MIR to compute layout.
1048
- DefKind :: Closure if tcx. is_coroutine ( def_id. to_def_id ( ) ) => ( false , true ) ,
1049
1052
// Full-fledged functions + closures
1050
1053
DefKind :: AssocFn | DefKind :: Fn | DefKind :: Closure => {
1051
1054
let generics = tcx. generics_of ( def_id) ;
@@ -1059,6 +1062,8 @@ fn should_encode_mir(
1059
1062
|| tcx. is_const_default_method ( def_id. to_def_id ( ) ) ;
1060
1063
( is_const_fn, opt)
1061
1064
}
1065
+ // Coroutines require optimized MIR to compute layout.
1066
+ DefKind :: Coroutine => ( false , true ) ,
1062
1067
// The others don't have MIR.
1063
1068
_ => ( false , false ) ,
1064
1069
}
@@ -1094,6 +1099,7 @@ fn should_encode_variances<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, def_kind: Def
1094
1099
| DefKind :: InlineConst
1095
1100
| DefKind :: GlobalAsm
1096
1101
| DefKind :: Closure
1102
+ | DefKind :: Coroutine
1097
1103
| DefKind :: ExternCrate => false ,
1098
1104
DefKind :: TyAlias => tcx. type_alias_is_lazy ( def_id) ,
1099
1105
}
@@ -1122,7 +1128,8 @@ fn should_encode_generics(def_kind: DefKind) -> bool {
1122
1128
| DefKind :: Impl { .. }
1123
1129
| DefKind :: Field
1124
1130
| DefKind :: TyParam
1125
- | DefKind :: Closure => true ,
1131
+ | DefKind :: Closure
1132
+ | DefKind :: Coroutine => true ,
1126
1133
DefKind :: Mod
1127
1134
| DefKind :: ForeignMod
1128
1135
| DefKind :: ConstParam
@@ -1151,6 +1158,7 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
1151
1158
| DefKind :: AssocFn
1152
1159
| DefKind :: AssocConst
1153
1160
| DefKind :: Closure
1161
+ | DefKind :: Coroutine
1154
1162
| DefKind :: ConstParam
1155
1163
| DefKind :: AnonConst
1156
1164
| DefKind :: InlineConst => true ,
@@ -1211,6 +1219,7 @@ fn should_encode_fn_sig(def_kind: DefKind) -> bool {
1211
1219
| DefKind :: Impl { .. }
1212
1220
| DefKind :: AssocConst
1213
1221
| DefKind :: Closure
1222
+ | DefKind :: Coroutine
1214
1223
| DefKind :: ConstParam
1215
1224
| DefKind :: AnonConst
1216
1225
| DefKind :: InlineConst
@@ -1249,6 +1258,7 @@ fn should_encode_constness(def_kind: DefKind) -> bool {
1249
1258
| DefKind :: OpaqueTy
1250
1259
| DefKind :: Impl { of_trait : false }
1251
1260
| DefKind :: ForeignTy
1261
+ | DefKind :: Coroutine
1252
1262
| DefKind :: ConstParam
1253
1263
| DefKind :: InlineConst
1254
1264
| DefKind :: AssocTy
@@ -1283,6 +1293,7 @@ fn should_encode_const(def_kind: DefKind) -> bool {
1283
1293
| DefKind :: Impl { .. }
1284
1294
| DefKind :: AssocFn
1285
1295
| DefKind :: Closure
1296
+ | DefKind :: Coroutine
1286
1297
| DefKind :: ConstParam
1287
1298
| DefKind :: AssocTy
1288
1299
| DefKind :: TyParam
@@ -1442,9 +1453,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1442
1453
self . encode_info_for_assoc_item ( def_id) ;
1443
1454
}
1444
1455
}
1445
- if def_kind == DefKind :: Closure
1446
- && let Some ( data) = self . tcx . coroutine_kind ( def_id)
1447
- {
1456
+ if let DefKind :: Coroutine = def_kind {
1457
+ let data = self . tcx . coroutine_kind ( def_id) . unwrap ( ) ;
1448
1458
record ! ( self . tables. coroutine_kind[ def_id] <- data) ;
1449
1459
}
1450
1460
if let DefKind :: Enum | DefKind :: Struct | DefKind :: Union = def_kind {
@@ -1626,7 +1636,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1626
1636
record ! ( self . tables. closure_saved_names_of_captured_variables[ def_id. to_def_id( ) ]
1627
1637
<- tcx. closure_saved_names_of_captured_variables( def_id) ) ;
1628
1638
1629
- if self . tcx . is_coroutine ( def_id. to_def_id ( ) )
1639
+ if let DefKind :: Coroutine = self . tcx . def_kind ( def_id)
1630
1640
&& let Some ( witnesses) = tcx. mir_coroutine_witnesses ( def_id)
1631
1641
{
1632
1642
record ! ( self . tables. mir_coroutine_witnesses[ def_id. to_def_id( ) ] <- witnesses) ;
@@ -1653,7 +1663,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1653
1663
}
1654
1664
record ! ( self . tables. promoted_mir[ def_id. to_def_id( ) ] <- tcx. promoted_mir( def_id) ) ;
1655
1665
1656
- if self . tcx . is_coroutine ( def_id. to_def_id ( ) )
1666
+ if let DefKind :: Coroutine = self . tcx . def_kind ( def_id)
1657
1667
&& let Some ( witnesses) = tcx. mir_coroutine_witnesses ( def_id)
1658
1668
{
1659
1669
record ! ( self . tables. mir_coroutine_witnesses[ def_id. to_def_id( ) ] <- witnesses) ;
0 commit comments