about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-05-10 06:12:14 +0200
committerGitHub <noreply@github.com>2023-05-10 06:12:14 +0200
commit3d4d6703a9d54b3285811813fc98b6b30abda03c (patch)
tree92d912538e297ea962b3b234b6fb8e9a4e23cf5f
parentd117b41409746d4970ffc886a8f54e49696fe06f (diff)
parentb7f570fff3e582e2ffb8bce3ea698b6bc8f4ccef (diff)
downloadrust-3d4d6703a9d54b3285811813fc98b6b30abda03c.tar.gz
rust-3d4d6703a9d54b3285811813fc98b6b30abda03c.zip
Rollup merge of #111381 - oli-obk:closure_attr, r=petrochenkov
Keep encoding attributes for closures

see https://github.com/model-checking/kani/pull/2406#issuecomment-1539630332 for some context.

We stopped encoding attributes for closures, but some tools need them
-rw-r--r--compiler/rustc_metadata/src/rmeta/encoder.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs
index 82c66b9dfb9..29cf432b8f9 100644
--- a/compiler/rustc_metadata/src/rmeta/encoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/encoder.rs
@@ -862,6 +862,11 @@ fn should_encode_attrs(def_kind: DefKind) -> bool {
         | DefKind::Macro(_)
         | DefKind::Field
         | DefKind::Impl { .. } => true,
+        // Tools may want to be able to detect their tool lints on
+        // closures from upstream crates, too. This is used by
+        // https://github.com/model-checking/kani and is not a performance
+        // or maintenance issue for us.
+        DefKind::Closure => true,
         DefKind::TyParam
         | DefKind::ConstParam
         | DefKind::Ctor(..)
@@ -874,7 +879,6 @@ fn should_encode_attrs(def_kind: DefKind) -> bool {
         | DefKind::ImplTraitPlaceholder
         | DefKind::LifetimeParam
         | DefKind::GlobalAsm
-        | DefKind::Closure
         | DefKind::Generator => false,
     }
 }