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