@@ -857,7 +857,8 @@ fn should_encode_span(def_kind: DefKind) -> bool {
857857 | DefKind :: OpaqueTy
858858 | DefKind :: Field
859859 | DefKind :: Impl { .. }
860- | DefKind :: Closure => true ,
860+ | DefKind :: Closure
861+ | DefKind :: Coroutine => true ,
861862 DefKind :: ForeignMod | DefKind :: GlobalAsm => false ,
862863 }
863864}
@@ -897,7 +898,8 @@ fn should_encode_attrs(def_kind: DefKind) -> bool {
897898 | DefKind :: InlineConst
898899 | DefKind :: OpaqueTy
899900 | DefKind :: LifetimeParam
900- | DefKind :: GlobalAsm => false ,
901+ | DefKind :: GlobalAsm
902+ | DefKind :: Coroutine => false ,
901903 }
902904}
903905
@@ -932,7 +934,8 @@ fn should_encode_expn_that_defined(def_kind: DefKind) -> bool {
932934 | DefKind :: Field
933935 | DefKind :: LifetimeParam
934936 | DefKind :: GlobalAsm
935- | DefKind :: Closure => false ,
937+ | DefKind :: Closure
938+ | DefKind :: Coroutine => false ,
936939 }
937940}
938941
@@ -967,6 +970,7 @@ fn should_encode_visibility(def_kind: DefKind) -> bool {
967970 | DefKind :: GlobalAsm
968971 | DefKind :: Impl { .. }
969972 | DefKind :: Closure
973+ | DefKind :: Coroutine
970974 | DefKind :: ExternCrate => false ,
971975 }
972976}
@@ -1002,6 +1006,7 @@ fn should_encode_stability(def_kind: DefKind) -> bool {
10021006 | DefKind :: InlineConst
10031007 | DefKind :: GlobalAsm
10041008 | DefKind :: Closure
1009+ | DefKind :: Coroutine
10051010 | DefKind :: ExternCrate => false ,
10061011 }
10071012}
@@ -1044,8 +1049,6 @@ fn should_encode_mir(
10441049 | DefKind :: AssocConst
10451050 | DefKind :: Static ( ..)
10461051 | 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 ) ,
10491052 // Full-fledged functions + closures
10501053 DefKind :: AssocFn | DefKind :: Fn | DefKind :: Closure => {
10511054 let generics = tcx. generics_of ( def_id) ;
@@ -1059,6 +1062,8 @@ fn should_encode_mir(
10591062 || tcx. is_const_default_method ( def_id. to_def_id ( ) ) ;
10601063 ( is_const_fn, opt)
10611064 }
1065+ // Coroutines require optimized MIR to compute layout.
1066+ DefKind :: Coroutine => ( false , true ) ,
10621067 // The others don't have MIR.
10631068 _ => ( false , false ) ,
10641069 }
@@ -1094,6 +1099,7 @@ fn should_encode_variances<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, def_kind: Def
10941099 | DefKind :: InlineConst
10951100 | DefKind :: GlobalAsm
10961101 | DefKind :: Closure
1102+ | DefKind :: Coroutine
10971103 | DefKind :: ExternCrate => false ,
10981104 DefKind :: TyAlias => tcx. type_alias_is_lazy ( def_id) ,
10991105 }
@@ -1122,7 +1128,8 @@ fn should_encode_generics(def_kind: DefKind) -> bool {
11221128 | DefKind :: Impl { .. }
11231129 | DefKind :: Field
11241130 | DefKind :: TyParam
1125- | DefKind :: Closure => true ,
1131+ | DefKind :: Closure
1132+ | DefKind :: Coroutine => true ,
11261133 DefKind :: Mod
11271134 | DefKind :: ForeignMod
11281135 | DefKind :: ConstParam
@@ -1151,6 +1158,7 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
11511158 | DefKind :: AssocFn
11521159 | DefKind :: AssocConst
11531160 | DefKind :: Closure
1161+ | DefKind :: Coroutine
11541162 | DefKind :: ConstParam
11551163 | DefKind :: AnonConst
11561164 | DefKind :: InlineConst => true ,
@@ -1211,6 +1219,7 @@ fn should_encode_fn_sig(def_kind: DefKind) -> bool {
12111219 | DefKind :: Impl { .. }
12121220 | DefKind :: AssocConst
12131221 | DefKind :: Closure
1222+ | DefKind :: Coroutine
12141223 | DefKind :: ConstParam
12151224 | DefKind :: AnonConst
12161225 | DefKind :: InlineConst
@@ -1249,6 +1258,7 @@ fn should_encode_constness(def_kind: DefKind) -> bool {
12491258 | DefKind :: OpaqueTy
12501259 | DefKind :: Impl { of_trait : false }
12511260 | DefKind :: ForeignTy
1261+ | DefKind :: Coroutine
12521262 | DefKind :: ConstParam
12531263 | DefKind :: InlineConst
12541264 | DefKind :: AssocTy
@@ -1283,6 +1293,7 @@ fn should_encode_const(def_kind: DefKind) -> bool {
12831293 | DefKind :: Impl { .. }
12841294 | DefKind :: AssocFn
12851295 | DefKind :: Closure
1296+ | DefKind :: Coroutine
12861297 | DefKind :: ConstParam
12871298 | DefKind :: AssocTy
12881299 | DefKind :: TyParam
@@ -1442,9 +1453,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14421453 self . encode_info_for_assoc_item ( def_id) ;
14431454 }
14441455 }
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 ( ) ;
14481458 record ! ( self . tables. coroutine_kind[ def_id] <- data) ;
14491459 }
14501460 if let DefKind :: Enum | DefKind :: Struct | DefKind :: Union = def_kind {
@@ -1626,7 +1636,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16261636 record ! ( self . tables. closure_saved_names_of_captured_variables[ def_id. to_def_id( ) ]
16271637 <- tcx. closure_saved_names_of_captured_variables( def_id) ) ;
16281638
1629- if self . tcx . is_coroutine ( def_id. to_def_id ( ) )
1639+ if let DefKind :: Coroutine = self . tcx . def_kind ( def_id)
16301640 && let Some ( witnesses) = tcx. mir_coroutine_witnesses ( def_id)
16311641 {
16321642 record ! ( self . tables. mir_coroutine_witnesses[ def_id. to_def_id( ) ] <- witnesses) ;
@@ -1653,7 +1663,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16531663 }
16541664 record ! ( self . tables. promoted_mir[ def_id. to_def_id( ) ] <- tcx. promoted_mir( def_id) ) ;
16551665
1656- if self . tcx . is_coroutine ( def_id. to_def_id ( ) )
1666+ if let DefKind :: Coroutine = self . tcx . def_kind ( def_id)
16571667 && let Some ( witnesses) = tcx. mir_coroutine_witnesses ( def_id)
16581668 {
16591669 record ! ( self . tables. mir_coroutine_witnesses[ def_id. to_def_id( ) ] <- witnesses) ;
0 commit comments