@@ -862,7 +862,7 @@ fn should_encode_span(def_kind: DefKind) -> bool {
862862 }
863863}
864864
865- fn should_encode_attrs ( def_kind : DefKind ) -> bool {
865+ fn should_encode_attrs ( def_kind : DefKind , is_coroutine : bool ) -> bool {
866866 match def_kind {
867867 DefKind :: Mod
868868 | DefKind :: Struct
@@ -886,7 +886,7 @@ fn should_encode_attrs(def_kind: DefKind) -> bool {
886886 // closures from upstream crates, too. This is used by
887887 // https://github.com/model-checking/kani and is not a performance
888888 // or maintenance issue for us.
889- DefKind :: Closure => true ,
889+ DefKind :: Closure => !is_coroutine ,
890890 DefKind :: TyParam
891891 | DefKind :: ConstParam
892892 | DefKind :: Ctor ( ..)
@@ -1228,11 +1228,11 @@ fn should_encode_fn_sig(def_kind: DefKind) -> bool {
12281228 }
12291229}
12301230
1231- fn should_encode_constness ( def_kind : DefKind ) -> bool {
1231+ fn should_encode_constness ( def_kind : DefKind , is_coroutine : bool ) -> bool {
12321232 match def_kind {
1233+ DefKind :: Closure => !is_coroutine,
12331234 DefKind :: Fn
12341235 | DefKind :: AssocFn
1235- | DefKind :: Closure
12361236 | DefKind :: Impl { of_trait : true }
12371237 | DefKind :: Variant
12381238 | DefKind :: Ctor ( ..) => true ,
@@ -1345,12 +1345,13 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13451345 for local_id in tcx. iter_local_def_id ( ) {
13461346 let def_id = local_id. to_def_id ( ) ;
13471347 let def_kind = tcx. def_kind ( local_id) ;
1348+ let is_coroutine = def_kind == DefKind :: Closure && tcx. is_coroutine ( def_id) ;
13481349 self . tables . def_kind . set_some ( def_id. index , def_kind) ;
13491350 if should_encode_span ( def_kind) {
13501351 let def_span = tcx. def_span ( local_id) ;
13511352 record ! ( self . tables. def_span[ def_id] <- def_span) ;
13521353 }
1353- if should_encode_attrs ( def_kind) {
1354+ if should_encode_attrs ( def_kind, is_coroutine ) {
13541355 self . encode_attrs ( local_id) ;
13551356 }
13561357 if should_encode_expn_that_defined ( def_kind) {
@@ -1405,7 +1406,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14051406 if should_encode_type ( tcx, local_id, def_kind) && !anon_const_without_hir {
14061407 record ! ( self . tables. type_of[ def_id] <- self . tcx. type_of( def_id) ) ;
14071408 }
1408- if should_encode_constness ( def_kind) {
1409+ if should_encode_constness ( def_kind, is_coroutine ) {
14091410 self . tables . constness . set_some ( def_id. index , self . tcx . constness ( def_id) ) ;
14101411 }
14111412 if let DefKind :: Fn | DefKind :: AssocFn = def_kind {
0 commit comments