@@ -856,8 +856,7 @@ fn should_encode_span(def_kind: DefKind) -> bool {
856856 | DefKind :: OpaqueTy
857857 | DefKind :: Field
858858 | DefKind :: Impl { .. }
859- | DefKind :: Closure
860- | DefKind :: Coroutine => true ,
859+ | DefKind :: Closure => true ,
861860 DefKind :: ForeignMod | DefKind :: GlobalAsm => false ,
862861 }
863862}
@@ -897,8 +896,7 @@ fn should_encode_attrs(def_kind: DefKind) -> bool {
897896 | DefKind :: InlineConst
898897 | DefKind :: OpaqueTy
899898 | DefKind :: LifetimeParam
900- | DefKind :: GlobalAsm
901- | DefKind :: Coroutine => false ,
899+ | DefKind :: GlobalAsm => false ,
902900 }
903901}
904902
@@ -933,8 +931,7 @@ fn should_encode_expn_that_defined(def_kind: DefKind) -> bool {
933931 | DefKind :: Field
934932 | DefKind :: LifetimeParam
935933 | DefKind :: GlobalAsm
936- | DefKind :: Closure
937- | DefKind :: Coroutine => false ,
934+ | DefKind :: Closure => false ,
938935 }
939936}
940937
@@ -969,7 +966,6 @@ fn should_encode_visibility(def_kind: DefKind) -> bool {
969966 | DefKind :: GlobalAsm
970967 | DefKind :: Impl { .. }
971968 | DefKind :: Closure
972- | DefKind :: Coroutine
973969 | DefKind :: ExternCrate => false ,
974970 }
975971}
@@ -1005,7 +1001,6 @@ fn should_encode_stability(def_kind: DefKind) -> bool {
10051001 | DefKind :: InlineConst
10061002 | DefKind :: GlobalAsm
10071003 | DefKind :: Closure
1008- | DefKind :: Coroutine
10091004 | DefKind :: ExternCrate => false ,
10101005 }
10111006}
@@ -1048,6 +1043,8 @@ fn should_encode_mir(
10481043 | DefKind :: AssocConst
10491044 | DefKind :: Static ( ..)
10501045 | 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 ) ,
10511048 // Full-fledged functions + closures
10521049 DefKind :: AssocFn | DefKind :: Fn | DefKind :: Closure => {
10531050 let generics = tcx. generics_of ( def_id) ;
@@ -1061,8 +1058,6 @@ fn should_encode_mir(
10611058 || tcx. is_const_default_method ( def_id. to_def_id ( ) ) ;
10621059 ( is_const_fn, opt)
10631060 }
1064- // Coroutines require optimized MIR to compute layout.
1065- DefKind :: Coroutine => ( false , true ) ,
10661061 // The others don't have MIR.
10671062 _ => ( false , false ) ,
10681063 }
@@ -1098,7 +1093,6 @@ fn should_encode_variances<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, def_kind: Def
10981093 | DefKind :: InlineConst
10991094 | DefKind :: GlobalAsm
11001095 | DefKind :: Closure
1101- | DefKind :: Coroutine
11021096 | DefKind :: ExternCrate => false ,
11031097 DefKind :: TyAlias => tcx. type_alias_is_lazy ( def_id) ,
11041098 }
@@ -1127,8 +1121,7 @@ fn should_encode_generics(def_kind: DefKind) -> bool {
11271121 | DefKind :: Impl { .. }
11281122 | DefKind :: Field
11291123 | DefKind :: TyParam
1130- | DefKind :: Closure
1131- | DefKind :: Coroutine => true ,
1124+ | DefKind :: Closure => true ,
11321125 DefKind :: Mod
11331126 | DefKind :: ForeignMod
11341127 | DefKind :: ConstParam
@@ -1157,7 +1150,6 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
11571150 | DefKind :: AssocFn
11581151 | DefKind :: AssocConst
11591152 | DefKind :: Closure
1160- | DefKind :: Coroutine
11611153 | DefKind :: ConstParam
11621154 | DefKind :: AnonConst
11631155 | DefKind :: InlineConst => true ,
@@ -1218,7 +1210,6 @@ fn should_encode_fn_sig(def_kind: DefKind) -> bool {
12181210 | DefKind :: Impl { .. }
12191211 | DefKind :: AssocConst
12201212 | DefKind :: Closure
1221- | DefKind :: Coroutine
12221213 | DefKind :: ConstParam
12231214 | DefKind :: AnonConst
12241215 | DefKind :: InlineConst
@@ -1257,7 +1248,6 @@ fn should_encode_constness(def_kind: DefKind) -> bool {
12571248 | DefKind :: OpaqueTy
12581249 | DefKind :: Impl { of_trait : false }
12591250 | DefKind :: ForeignTy
1260- | DefKind :: Coroutine
12611251 | DefKind :: ConstParam
12621252 | DefKind :: InlineConst
12631253 | DefKind :: AssocTy
@@ -1292,7 +1282,6 @@ fn should_encode_const(def_kind: DefKind) -> bool {
12921282 | DefKind :: Impl { .. }
12931283 | DefKind :: AssocFn
12941284 | DefKind :: Closure
1295- | DefKind :: Coroutine
12961285 | DefKind :: ConstParam
12971286 | DefKind :: AssocTy
12981287 | DefKind :: TyParam
@@ -1452,8 +1441,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14521441 self . encode_info_for_assoc_item ( def_id) ;
14531442 }
14541443 }
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+ {
14571447 record ! ( self . tables. coroutine_kind[ def_id] <- data) ;
14581448 }
14591449 if let DefKind :: Enum | DefKind :: Struct | DefKind :: Union = def_kind {
@@ -1635,7 +1625,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16351625 record ! ( self . tables. closure_saved_names_of_captured_variables[ def_id. to_def_id( ) ]
16361626 <- tcx. closure_saved_names_of_captured_variables( def_id) ) ;
16371627
1638- if let DefKind :: Coroutine = self . tcx . def_kind ( def_id)
1628+ if self . tcx . is_coroutine ( def_id. to_def_id ( ) )
16391629 && let Some ( witnesses) = tcx. mir_coroutine_witnesses ( def_id)
16401630 {
16411631 record ! ( self . tables. mir_coroutine_witnesses[ def_id. to_def_id( ) ] <- witnesses) ;
@@ -1662,7 +1652,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16621652 }
16631653 record ! ( self . tables. promoted_mir[ def_id. to_def_id( ) ] <- tcx. promoted_mir( def_id) ) ;
16641654
1665- if let DefKind :: Coroutine = self . tcx . def_kind ( def_id)
1655+ if self . tcx . is_coroutine ( def_id. to_def_id ( ) )
16661656 && let Some ( witnesses) = tcx. mir_coroutine_witnesses ( def_id)
16671657 {
16681658 record ! ( self . tables. mir_coroutine_witnesses[ def_id. to_def_id( ) ] <- witnesses) ;
0 commit comments