@@ -862,7 +862,7 @@ fn should_encode_span(def_kind: DefKind) -> bool {
862
862
}
863
863
}
864
864
865
- fn should_encode_attrs ( def_kind : DefKind ) -> bool {
865
+ fn should_encode_attrs ( def_kind : DefKind , is_coroutine : bool ) -> bool {
866
866
match def_kind {
867
867
DefKind :: Mod
868
868
| DefKind :: Struct
@@ -886,7 +886,7 @@ fn should_encode_attrs(def_kind: DefKind) -> bool {
886
886
// closures from upstream crates, too. This is used by
887
887
// https://github.com/model-checking/kani and is not a performance
888
888
// or maintenance issue for us.
889
- DefKind :: Closure => true ,
889
+ DefKind :: Closure => !is_coroutine ,
890
890
DefKind :: TyParam
891
891
| DefKind :: ConstParam
892
892
| DefKind :: Ctor ( ..)
@@ -1228,11 +1228,11 @@ fn should_encode_fn_sig(def_kind: DefKind) -> bool {
1228
1228
}
1229
1229
}
1230
1230
1231
- fn should_encode_constness ( def_kind : DefKind ) -> bool {
1231
+ fn should_encode_constness ( def_kind : DefKind , is_coroutine : bool ) -> bool {
1232
1232
match def_kind {
1233
+ DefKind :: Closure => !is_coroutine,
1233
1234
DefKind :: Fn
1234
1235
| DefKind :: AssocFn
1235
- | DefKind :: Closure
1236
1236
| DefKind :: Impl { of_trait : true }
1237
1237
| DefKind :: Variant
1238
1238
| DefKind :: Ctor ( ..) => true ,
@@ -1345,12 +1345,13 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1345
1345
for local_id in tcx. iter_local_def_id ( ) {
1346
1346
let def_id = local_id. to_def_id ( ) ;
1347
1347
let def_kind = tcx. def_kind ( local_id) ;
1348
+ let is_coroutine = def_kind == DefKind :: Closure && tcx. is_coroutine ( def_id) ;
1348
1349
self . tables . def_kind . set_some ( def_id. index , def_kind) ;
1349
1350
if should_encode_span ( def_kind) {
1350
1351
let def_span = tcx. def_span ( local_id) ;
1351
1352
record ! ( self . tables. def_span[ def_id] <- def_span) ;
1352
1353
}
1353
- if should_encode_attrs ( def_kind) {
1354
+ if should_encode_attrs ( def_kind, is_coroutine ) {
1354
1355
self . encode_attrs ( local_id) ;
1355
1356
}
1356
1357
if should_encode_expn_that_defined ( def_kind) {
@@ -1405,7 +1406,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1405
1406
if should_encode_type ( tcx, local_id, def_kind) && !anon_const_without_hir {
1406
1407
record ! ( self . tables. type_of[ def_id] <- self . tcx. type_of( def_id) ) ;
1407
1408
}
1408
- if should_encode_constness ( def_kind) {
1409
+ if should_encode_constness ( def_kind, is_coroutine ) {
1409
1410
self . tables . constness . set_some ( def_id. index , self . tcx . constness ( def_id) ) ;
1410
1411
}
1411
1412
if let DefKind :: Fn | DefKind :: AssocFn = def_kind {
0 commit comments