about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_ast/src/ast.rs2
-rw-r--r--compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs2
-rw-r--r--compiler/rustc_lint/src/levels.rs2
-rw-r--r--compiler/rustc_macros/src/newtype.rs22
-rw-r--r--compiler/rustc_span/src/def_id.rs5
-rw-r--r--compiler/rustc_span/src/hygiene.rs4
6 files changed, 19 insertions, 18 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs
index f933b9b161c..49649188f58 100644
--- a/compiler/rustc_ast/src/ast.rs
+++ b/compiler/rustc_ast/src/ast.rs
@@ -2554,8 +2554,8 @@ pub enum AttrStyle {
 }
 
 rustc_index::newtype_index! {
+    #[custom_encodable]
     pub struct AttrId {
-        ENCODABLE = custom
         DEBUG_FORMAT = "AttrId({})"
     }
 }
diff --git a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs
index 972769eb197..6531e55c577 100644
--- a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs
@@ -198,8 +198,8 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
             // entire graph when there are many connected regions.
 
             rustc_index::newtype_index! {
+                #[custom_encodable]
                 pub struct RegionId {
-                    ENCODABLE = custom
                 }
             }
             struct ConnectedRegion {
diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs
index 847c356b83c..7fed40b201b 100644
--- a/compiler/rustc_lint/src/levels.rs
+++ b/compiler/rustc_lint/src/levels.rs
@@ -39,8 +39,8 @@ struct LintLevelSets {
 }
 
 rustc_index::newtype_index! {
+    #[custom_encodable] // we don't need encoding
     struct LintStackIndex {
-        ENCODABLE = custom, // we don't need encoding
         const COMMAND_LINE = 0,
     }
 }
diff --git a/compiler/rustc_macros/src/newtype.rs b/compiler/rustc_macros/src/newtype.rs
index 46f5ead5942..2e28e9fb49d 100644
--- a/compiler/rustc_macros/src/newtype.rs
+++ b/compiler/rustc_macros/src/newtype.rs
@@ -6,7 +6,6 @@ use syn::*;
 mod kw {
     syn::custom_keyword!(DEBUG_FORMAT);
     syn::custom_keyword!(MAX);
-    syn::custom_keyword!(ENCODABLE);
     syn::custom_keyword!(custom);
     syn::custom_keyword!(ORD_IMPL);
 }
@@ -27,7 +26,7 @@ struct Newtype(TokenStream);
 
 impl Parse for Newtype {
     fn parse(input: ParseStream<'_>) -> Result<Self> {
-        let attrs = input.call(Attribute::parse_outer)?;
+        let mut attrs = input.call(Attribute::parse_outer)?;
         let vis: Visibility = input.parse()?;
         input.parse::<Token![struct]>()?;
         let name: Ident = input.parse()?;
@@ -51,6 +50,17 @@ impl Parse for Newtype {
             Ok(())
         };
 
+        attrs.retain(|attr| match attr.path.get_ident() {
+            Some(ident) => match &*ident.to_string() {
+                "custom_encodable" => {
+                    encodable = false;
+                    false
+                }
+                _ => true,
+            },
+            _ => true,
+        });
+
         if body.lookahead1().peek(Token![..]) {
             body.parse::<Token![..]>()?;
         } else {
@@ -81,14 +91,6 @@ impl Parse for Newtype {
                     }
                     continue;
                 }
-                if body.lookahead1().peek(kw::ENCODABLE) {
-                    body.parse::<kw::ENCODABLE>()?;
-                    body.parse::<Token![=]>()?;
-                    body.parse::<kw::custom>()?;
-                    try_comma()?;
-                    encodable = false;
-                    continue;
-                }
                 if body.lookahead1().peek(kw::ORD_IMPL) {
                     body.parse::<kw::ORD_IMPL>()?;
                     body.parse::<Token![=]>()?;
diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs
index e62ce2c266a..326dce7838d 100644
--- a/compiler/rustc_span/src/def_id.rs
+++ b/compiler/rustc_span/src/def_id.rs
@@ -10,8 +10,8 @@ use std::fmt;
 use std::hash::{Hash, Hasher};
 
 rustc_index::newtype_index! {
+    #[custom_encodable]
     pub struct CrateNum {
-        ENCODABLE = custom
         DEBUG_FORMAT = "crate{}"
     }
 }
@@ -194,9 +194,8 @@ rustc_index::newtype_index! {
     /// A DefIndex is an index into the hir-map for a crate, identifying a
     /// particular definition. It should really be considered an interned
     /// shorthand for a particular DefPath.
+    #[custom_encodable] // (only encodable in metadata)
     pub struct DefIndex {
-        ENCODABLE = custom // (only encodable in metadata)
-
         DEBUG_FORMAT = "DefIndex({})",
         /// The crate root is always assigned index 0 by the AST Map code,
         /// thanks to `NodeCollector::new`.
diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs
index 038699154c7..4fb56dac856 100644
--- a/compiler/rustc_span/src/hygiene.rs
+++ b/compiler/rustc_span/src/hygiene.rs
@@ -61,8 +61,8 @@ pub struct SyntaxContextData {
 
 rustc_index::newtype_index! {
     /// A unique ID associated with a macro invocation and expansion.
+    #[custom_encodable]
     pub struct ExpnIndex {
-        ENCODABLE = custom
     }
 }
 
@@ -82,8 +82,8 @@ impl fmt::Debug for ExpnId {
 
 rustc_index::newtype_index! {
     /// A unique ID associated with a macro invocation and expansion.
+    #[custom_encodable]
     pub struct LocalExpnId {
-        ENCODABLE = custom
         ORD_IMPL = custom
         DEBUG_FORMAT = "expn{}"
     }