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