diff --git a/compiler/rustc_macros/src/newtype.rs b/compiler/rustc_macros/src/newtype.rs index fd3f5225155..46f5ead5942 100644 --- a/compiler/rustc_macros/src/newtype.rs +++ b/compiler/rustc_macros/src/newtype.rs @@ -1,11 +1,9 @@ use proc_macro2::{Span, TokenStream}; use quote::quote; use syn::parse::*; -use syn::punctuated::Punctuated; use syn::*; mod kw { - syn::custom_keyword!(derive); syn::custom_keyword!(DEBUG_FORMAT); syn::custom_keyword!(MAX); syn::custom_keyword!(ENCODABLE); @@ -57,16 +55,6 @@ impl Parse for Newtype { body.parse::()?; } else { loop { - if body.lookahead1().peek(kw::derive) { - body.parse::()?; - let derives; - bracketed!(derives in body); - let derives: Punctuated = - derives.parse_terminated(Path::parse)?; - try_comma()?; - derive_paths.extend(derives); - continue; - } if body.lookahead1().peek(kw::DEBUG_FORMAT) { body.parse::()?; body.parse::()?; diff --git a/compiler/rustc_middle/src/middle/region.rs b/compiler/rustc_middle/src/middle/region.rs index c886175c6ea..dfe71dc9257 100644 --- a/compiler/rustc_middle/src/middle/region.rs +++ b/compiler/rustc_middle/src/middle/region.rs @@ -147,8 +147,8 @@ rustc_index::newtype_index! { /// /// * The subscope with `first_statement_index == 1` is scope of `c`, /// and thus does not include EXPR_2, but covers the `...`. + #[derive(HashStable)] pub struct FirstStatementIndex { - derive [HashStable] } } diff --git a/compiler/rustc_middle/src/mir/coverage.rs b/compiler/rustc_middle/src/mir/coverage.rs index 0b55757eb03..173c8967eec 100644 --- a/compiler/rustc_middle/src/mir/coverage.rs +++ b/compiler/rustc_middle/src/mir/coverage.rs @@ -10,8 +10,8 @@ rustc_index::newtype_index! { /// CounterValueReference.as_u32() (which ascend from 1) or an ExpressionOperandId.as_u32() /// (which _*descend*_ from u32::MAX). Id value `0` (zero) represents a virtual counter with a /// constant value of `0`. + #[derive(HashStable)] pub struct ExpressionOperandId { - derive [HashStable] DEBUG_FORMAT = "ExpressionOperandId({})", MAX = 0xFFFF_FFFF, } @@ -32,8 +32,8 @@ impl ExpressionOperandId { } rustc_index::newtype_index! { + #[derive(HashStable)] pub struct CounterValueReference { - derive [HashStable] DEBUG_FORMAT = "CounterValueReference({})", MAX = 0xFFFF_FFFF, } @@ -56,8 +56,8 @@ rustc_index::newtype_index! { /// InjectedExpressionId.as_u32() converts to ExpressionOperandId.as_u32() /// /// Values descend from u32::MAX. + #[derive(HashStable)] pub struct InjectedExpressionId { - derive [HashStable] DEBUG_FORMAT = "InjectedExpressionId({})", MAX = 0xFFFF_FFFF, } @@ -67,8 +67,8 @@ rustc_index::newtype_index! { /// InjectedExpressionIndex.as_u32() translates to u32::MAX - ExpressionOperandId.as_u32() /// /// Values ascend from 0. + #[derive(HashStable)] pub struct InjectedExpressionIndex { - derive [HashStable] DEBUG_FORMAT = "InjectedExpressionIndex({})", MAX = 0xFFFF_FFFF, } @@ -78,8 +78,8 @@ rustc_index::newtype_index! { /// MappedExpressionIndex values ascend from zero, and are recalculated indexes based on their /// array position in the LLVM coverage map "Expressions" array, which is assembled during the /// "mapgen" process. They cannot be computed algorithmically, from the other `newtype_index`s. + #[derive(HashStable)] pub struct MappedExpressionIndex { - derive [HashStable] DEBUG_FORMAT = "MappedExpressionIndex({})", MAX = 0xFFFF_FFFF, } diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index e909b2f74aa..0b4fc253fef 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -654,8 +654,8 @@ impl SourceInfo { // Variables and temps rustc_index::newtype_index! { + #[derive(HashStable)] pub struct Local { - derive [HashStable] DEBUG_FORMAT = "_{}", const RETURN_PLACE = 0, } @@ -1146,8 +1146,8 @@ rustc_index::newtype_index! { /// https://rustc-dev-guide.rust-lang.org/appendix/background.html#what-is-a-dataflow-analysis /// [`CriticalCallEdges`]: ../../rustc_const_eval/transform/add_call_guards/enum.AddCallGuards.html#variant.CriticalCallEdges /// [guide-mir]: https://rustc-dev-guide.rust-lang.org/mir/ + #[derive(HashStable)] pub struct BasicBlock { - derive [HashStable] DEBUG_FORMAT = "bb{}", const START_BLOCK = 0, } @@ -1530,8 +1530,8 @@ rustc_index::newtype_index! { /// [wrapper]: https://rustc-dev-guide.rust-lang.org/appendix/glossary.html#newtype /// [CFG]: https://rustc-dev-guide.rust-lang.org/appendix/background.html#cfg /// [mir-datatypes]: https://rustc-dev-guide.rust-lang.org/mir/index.html#mir-data-types + #[derive(HashStable)] pub struct Field { - derive [HashStable] DEBUG_FORMAT = "field[{}]" } } @@ -1757,8 +1757,8 @@ impl Debug for Place<'_> { // Scopes rustc_index::newtype_index! { + #[derive(HashStable)] pub struct SourceScope { - derive [HashStable] DEBUG_FORMAT = "scope[{}]", const OUTERMOST_SOURCE_SCOPE = 0, } @@ -2755,8 +2755,8 @@ impl<'tcx> TypeVisitable<'tcx> for UserTypeProjection { } rustc_index::newtype_index! { + #[derive(HashStable)] pub struct Promoted { - derive [HashStable] DEBUG_FORMAT = "promoted[{}]" } } diff --git a/compiler/rustc_middle/src/mir/query.rs b/compiler/rustc_middle/src/mir/query.rs index efd7357afc4..4db3ded34ea 100644 --- a/compiler/rustc_middle/src/mir/query.rs +++ b/compiler/rustc_middle/src/mir/query.rs @@ -130,8 +130,8 @@ pub struct UnsafetyCheckResult { } rustc_index::newtype_index! { + #[derive(HashStable)] pub struct GeneratorSavedLocal { - derive [HashStable] DEBUG_FORMAT = "_{}", } } diff --git a/compiler/rustc_middle/src/ty/typeck_results.rs b/compiler/rustc_middle/src/ty/typeck_results.rs index 4fe85d4366f..1a8927558c9 100644 --- a/compiler/rustc_middle/src/ty/typeck_results.rs +++ b/compiler/rustc_middle/src/ty/typeck_results.rs @@ -608,8 +608,8 @@ impl<'a, V> LocalTableInContextMut<'a, V> { } rustc_index::newtype_index! { + #[derive(HashStable)] pub struct UserTypeAnnotationIndex { - derive [HashStable] DEBUG_FORMAT = "UserType({})", const START_INDEX = 0, } diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs index 53c9878ab87..c60de3cb0b2 100644 --- a/compiler/rustc_target/src/abi/mod.rs +++ b/compiler/rustc_target/src/abi/mod.rs @@ -20,8 +20,8 @@ impl ToJson for Endian { } rustc_index::newtype_index! { + #[derive(HashStable_Generic)] pub struct VariantIdx { - derive [HashStable_Generic] } }