@@ -857,8 +857,7 @@ fn should_encode_span(def_kind: DefKind) -> bool {
857857 | DefKind :: OpaqueTy
858858 | DefKind :: Field
859859 | DefKind :: Impl { .. }
860- | DefKind :: Closure
861- | DefKind :: Coroutine => true ,
860+ | DefKind :: Closure => true ,
862861 DefKind :: ForeignMod | DefKind :: GlobalAsm => false ,
863862 }
864863}
@@ -898,8 +897,7 @@ fn should_encode_attrs(def_kind: DefKind) -> bool {
898897 | DefKind :: InlineConst
899898 | DefKind :: OpaqueTy
900899 | DefKind :: LifetimeParam
901- | DefKind :: GlobalAsm
902- | DefKind :: Coroutine => false ,
900+ | DefKind :: GlobalAsm => false ,
903901 }
904902}
905903
@@ -934,8 +932,7 @@ fn should_encode_expn_that_defined(def_kind: DefKind) -> bool {
934932 | DefKind :: Field
935933 | DefKind :: LifetimeParam
936934 | DefKind :: GlobalAsm
937- | DefKind :: Closure
938- | DefKind :: Coroutine => false ,
935+ | DefKind :: Closure => false ,
939936 }
940937}
941938
@@ -970,7 +967,6 @@ fn should_encode_visibility(def_kind: DefKind) -> bool {
970967 | DefKind :: GlobalAsm
971968 | DefKind :: Impl { .. }
972969 | DefKind :: Closure
973- | DefKind :: Coroutine
974970 | DefKind :: ExternCrate => false ,
975971 }
976972}
@@ -1006,7 +1002,6 @@ fn should_encode_stability(def_kind: DefKind) -> bool {
10061002 | DefKind :: InlineConst
10071003 | DefKind :: GlobalAsm
10081004 | DefKind :: Closure
1009- | DefKind :: Coroutine
10101005 | DefKind :: ExternCrate => false ,
10111006 }
10121007}
@@ -1049,6 +1044,8 @@ fn should_encode_mir(
10491044 | DefKind :: AssocConst
10501045 | DefKind :: Static ( ..)
10511046 | 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 ) ,
10521049 // Full-fledged functions + closures
10531050 DefKind :: AssocFn | DefKind :: Fn | DefKind :: Closure => {
10541051 let generics = tcx. generics_of ( def_id) ;
@@ -1062,8 +1059,6 @@ fn should_encode_mir(
10621059 || tcx. is_const_default_method ( def_id. to_def_id ( ) ) ;
10631060 ( is_const_fn, opt)
10641061 }
1065- // Coroutines require optimized MIR to compute layout.
1066- DefKind :: Coroutine => ( false , true ) ,
10671062 // The others don't have MIR.
10681063 _ => ( false , false ) ,
10691064 }
@@ -1099,7 +1094,6 @@ fn should_encode_variances<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, def_kind: Def
10991094 | DefKind :: InlineConst
11001095 | DefKind :: GlobalAsm
11011096 | DefKind :: Closure
1102- | DefKind :: Coroutine
11031097 | DefKind :: ExternCrate => false ,
11041098 DefKind :: TyAlias => tcx. type_alias_is_lazy ( def_id) ,
11051099 }
@@ -1128,8 +1122,7 @@ fn should_encode_generics(def_kind: DefKind) -> bool {
11281122 | DefKind :: Impl { .. }
11291123 | DefKind :: Field
11301124 | DefKind :: TyParam
1131- | DefKind :: Closure
1132- | DefKind :: Coroutine => true ,
1125+ | DefKind :: Closure => true ,
11331126 DefKind :: Mod
11341127 | DefKind :: ForeignMod
11351128 | DefKind :: ConstParam
@@ -1158,7 +1151,6 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
11581151 | DefKind :: AssocFn
11591152 | DefKind :: AssocConst
11601153 | DefKind :: Closure
1161- | DefKind :: Coroutine
11621154 | DefKind :: ConstParam
11631155 | DefKind :: AnonConst
11641156 | DefKind :: InlineConst => true ,
@@ -1219,7 +1211,6 @@ fn should_encode_fn_sig(def_kind: DefKind) -> bool {
12191211 | DefKind :: Impl { .. }
12201212 | DefKind :: AssocConst
12211213 | DefKind :: Closure
1222- | DefKind :: Coroutine
12231214 | DefKind :: ConstParam
12241215 | DefKind :: AnonConst
12251216 | DefKind :: InlineConst
@@ -1258,7 +1249,6 @@ fn should_encode_constness(def_kind: DefKind) -> bool {
12581249 | DefKind :: OpaqueTy
12591250 | DefKind :: Impl { of_trait : false }
12601251 | DefKind :: ForeignTy
1261- | DefKind :: Coroutine
12621252 | DefKind :: ConstParam
12631253 | DefKind :: InlineConst
12641254 | DefKind :: AssocTy
@@ -1293,7 +1283,6 @@ fn should_encode_const(def_kind: DefKind) -> bool {
12931283 | DefKind :: Impl { .. }
12941284 | DefKind :: AssocFn
12951285 | DefKind :: Closure
1296- | DefKind :: Coroutine
12971286 | DefKind :: ConstParam
12981287 | DefKind :: AssocTy
12991288 | DefKind :: TyParam
@@ -1453,8 +1442,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14531442 self . encode_info_for_assoc_item ( def_id) ;
14541443 }
14551444 }
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+ {
14581448 record ! ( self . tables. coroutine_kind[ def_id] <- data) ;
14591449 }
14601450 if let DefKind :: Enum | DefKind :: Struct | DefKind :: Union = def_kind {
@@ -1636,7 +1626,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16361626 record ! ( self . tables. closure_saved_names_of_captured_variables[ def_id. to_def_id( ) ]
16371627 <- tcx. closure_saved_names_of_captured_variables( def_id) ) ;
16381628
1639- if let DefKind :: Coroutine = self . tcx . def_kind ( def_id)
1629+ if self . tcx . is_coroutine ( def_id. to_def_id ( ) )
16401630 && let Some ( witnesses) = tcx. mir_coroutine_witnesses ( def_id)
16411631 {
16421632 record ! ( self . tables. mir_coroutine_witnesses[ def_id. to_def_id( ) ] <- witnesses) ;
@@ -1663,7 +1653,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16631653 }
16641654 record ! ( self . tables. promoted_mir[ def_id. to_def_id( ) ] <- tcx. promoted_mir( def_id) ) ;
16651655
1666- if let DefKind :: Coroutine = self . tcx . def_kind ( def_id)
1656+ if self . tcx . is_coroutine ( def_id. to_def_id ( ) )
16671657 && let Some ( witnesses) = tcx. mir_coroutine_witnesses ( def_id)
16681658 {
16691659 record ! ( self . tables. mir_coroutine_witnesses[ def_id. to_def_id( ) ] <- witnesses) ;
0 commit comments