1
Fork 0

Use proc_macro for HashStable derive in libsyntax.

This commit is contained in:
Camille GILLOT 2019-11-09 20:56:19 +01:00
parent 5b0e702f6c
commit c2e1658c67
6 changed files with 23 additions and 49 deletions

View file

@ -4411,6 +4411,7 @@ dependencies = [
"rustc_errors", "rustc_errors",
"rustc_index", "rustc_index",
"rustc_lexer", "rustc_lexer",
"rustc_macros",
"scoped-tls", "scoped-tls",
"serialize", "serialize",
"smallvec 1.0.0", "smallvec 1.0.0",

View file

@ -55,11 +55,6 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for ast::Name {
} }
} }
impl_stable_hash_for!(enum ::syntax::ast::AsmDialect {
Att,
Intel
});
impl_stable_hash_for!(enum ::syntax_pos::hygiene::MacroKind { impl_stable_hash_for!(enum ::syntax_pos::hygiene::MacroKind {
Bang, Bang,
Attr, Attr,
@ -124,22 +119,6 @@ for ::syntax::attr::StabilityLevel {
impl_stable_hash_for!(struct ::syntax::attr::RustcDeprecation { since, reason, suggestion }); impl_stable_hash_for!(struct ::syntax::attr::RustcDeprecation { since, reason, suggestion });
impl_stable_hash_for!(enum ::syntax::attr::IntType {
SignedInt(int_ty),
UnsignedInt(uint_ty)
});
impl_stable_hash_for!(enum ::syntax::ast::LitIntType {
Signed(int_ty),
Unsigned(int_ty),
Unsuffixed
});
impl_stable_hash_for!(enum ::syntax::ast::LitFloatType {
Suffixed(float_ty),
Unsuffixed
});
impl_stable_hash_for!(struct ::syntax::ast::Lit { impl_stable_hash_for!(struct ::syntax::ast::Lit {
kind, kind,
token, token,
@ -159,19 +138,7 @@ impl_stable_hash_for!(enum ::syntax::ast::LitKind {
impl_stable_hash_for_spanned!(::syntax::ast::LitKind); impl_stable_hash_for_spanned!(::syntax::ast::LitKind);
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 });
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 });
impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });
impl_stable_hash_for!(enum ::syntax::ast::Defaultness { Default, Final });
impl_stable_hash_for!(struct ::syntax::ast::Lifetime { id, ident }); impl_stable_hash_for!(struct ::syntax::ast::Lifetime { id, ident });
impl_stable_hash_for!(enum ::syntax::ast::StrStyle { Cooked, Raw(pounds) });
impl_stable_hash_for!(enum ::syntax::ast::AttrStyle { Outer, Inner });
impl_stable_hash_for!(enum ::syntax::ast::Movability { Static, Movable });
impl_stable_hash_for!(enum ::syntax::ast::CaptureBy { Value, Ref });
impl_stable_hash_for!(enum ::syntax::ast::IsAuto { Yes, No });
impl_stable_hash_for!(enum ::syntax::ast::ImplPolarity { Positive, Negative });
impl<'a> HashStable<StableHashingContext<'a>> for [ast::Attribute] { impl<'a> HashStable<StableHashingContext<'a>> for [ast::Attribute] {
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {

View file

@ -20,5 +20,6 @@ errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_data_structures = { path = "../librustc_data_structures" } rustc_data_structures = { path = "../librustc_data_structures" }
rustc_index = { path = "../librustc_index" } rustc_index = { path = "../librustc_index" }
rustc_lexer = { path = "../librustc_lexer" } rustc_lexer = { path = "../librustc_lexer" }
rustc_macros = { path = "../librustc_macros" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] } smallvec = { version = "1.0", features = ["union", "may_dangle"] }
rustc_error_codes = { path = "../librustc_error_codes" } rustc_error_codes = { path = "../librustc_error_codes" }

View file

@ -1328,7 +1328,7 @@ pub struct QSelf {
} }
/// A capture clause used in closures and `async` blocks. /// A capture clause used in closures and `async` blocks.
#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)] #[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
pub enum CaptureBy { pub enum CaptureBy {
/// `move |x| y + x`. /// `move |x| y + x`.
Value, Value,
@ -1339,7 +1339,7 @@ pub enum CaptureBy {
/// The movability of a generator / closure literal: /// The movability of a generator / closure literal:
/// whether a generator contains self-references, causing it to be `!Unpin`. /// whether a generator contains self-references, causing it to be `!Unpin`.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
RustcEncodable, RustcDecodable, Debug, Copy)] RustcEncodable, RustcDecodable, Debug, Copy, HashStable_Generic)]
pub enum Movability { pub enum Movability {
/// May contain self-references, `!Unpin`. /// May contain self-references, `!Unpin`.
Static, Static,
@ -1400,7 +1400,7 @@ impl MacroDef {
} }
// Clippy uses Hash and PartialEq // Clippy uses Hash and PartialEq
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy, Hash, PartialEq)] #[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy, Hash, PartialEq, HashStable_Generic)]
pub enum StrStyle { pub enum StrStyle {
/// A regular string, like `"foo"`. /// A regular string, like `"foo"`.
Cooked, Cooked,
@ -1451,7 +1451,7 @@ impl StrLit {
// Clippy uses Hash and PartialEq // Clippy uses Hash and PartialEq
/// Type of the integer literal based on provided suffix. /// Type of the integer literal based on provided suffix.
#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq)] #[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq, HashStable_Generic)]
pub enum LitIntType { pub enum LitIntType {
/// e.g. `42_i32`. /// e.g. `42_i32`.
Signed(IntTy), Signed(IntTy),
@ -1462,7 +1462,7 @@ pub enum LitIntType {
} }
/// Type of the float literal based on provided suffix. /// Type of the float literal based on provided suffix.
#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq)] #[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq, HashStable_Generic)]
pub enum LitFloatType { pub enum LitFloatType {
/// A float literal with a suffix (`1f32` or `1E10f32`). /// A float literal with a suffix (`1f32` or `1E10f32`).
Suffixed(FloatTy), Suffixed(FloatTy),
@ -1609,7 +1609,8 @@ pub enum ImplItemKind {
Macro(Mac), Macro(Mac),
} }
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable_Generic,
RustcEncodable, RustcDecodable, Debug)]
pub enum FloatTy { pub enum FloatTy {
F32, F32,
F64, F64,
@ -1638,7 +1639,8 @@ impl FloatTy {
} }
} }
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable_Generic,
RustcEncodable, RustcDecodable, Debug)]
pub enum IntTy { pub enum IntTy {
Isize, Isize,
I8, I8,
@ -1690,7 +1692,8 @@ impl IntTy {
} }
} }
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Copy, Debug)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable_Generic,
RustcEncodable, RustcDecodable, Copy, Debug)]
pub enum UintTy { pub enum UintTy {
Usize, Usize,
U8, U8,
@ -1863,7 +1866,7 @@ pub enum TraitObjectSyntax {
/// Inline assembly dialect. /// Inline assembly dialect.
/// ///
/// E.g., `"intel"` as in `asm!("mov eax, 2" : "={eax}"(result) : : : "intel")`. /// E.g., `"intel"` as in `asm!("mov eax, 2" : "={eax}"(result) : : : "intel")`.
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] #[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy, HashStable_Generic)]
pub enum AsmDialect { pub enum AsmDialect {
Att, Att,
Intel, Intel,
@ -2021,14 +2024,14 @@ impl FnDecl {
} }
/// Is the trait definition an auto trait? /// Is the trait definition an auto trait?
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)] #[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
pub enum IsAuto { pub enum IsAuto {
Yes, Yes,
No, No,
} }
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
RustcEncodable, RustcDecodable, Debug)] RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
pub enum Unsafety { pub enum Unsafety {
Unsafe, Unsafe,
Normal, Normal,
@ -2085,7 +2088,7 @@ impl IsAsync {
} }
} }
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)] #[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
pub enum Constness { pub enum Constness {
Const, Const,
NotConst, NotConst,
@ -2093,13 +2096,13 @@ pub enum Constness {
/// Item defaultness. /// Item defaultness.
/// For details see the [RFC #2532](https://github.com/rust-lang/rfcs/pull/2532). /// For details see the [RFC #2532](https://github.com/rust-lang/rfcs/pull/2532).
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)] #[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
pub enum Defaultness { pub enum Defaultness {
Default, Default,
Final, Final,
} }
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] #[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable_Generic)]
pub enum ImplPolarity { pub enum ImplPolarity {
/// `impl Trait for Type` /// `impl Trait for Type`
Positive, Positive,
@ -2233,7 +2236,7 @@ impl UseTree {
/// Distinguishes between `Attribute`s that decorate items and Attributes that /// Distinguishes between `Attribute`s that decorate items and Attributes that
/// are contained as statements within items. These two cases need to be /// are contained as statements within items. These two cases need to be
/// distinguished for pretty-printing. /// distinguished for pretty-printing.
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] #[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy, HashStable_Generic)]
pub enum AttrStyle { pub enum AttrStyle {
Outer, Outer,
Inner, Inner,

View file

@ -763,7 +763,7 @@ pub enum ReprAttr {
ReprAlign(u32), ReprAlign(u32),
} }
#[derive(Eq, PartialEq, Debug, RustcEncodable, RustcDecodable, Copy, Clone)] #[derive(Eq, PartialEq, Debug, RustcEncodable, RustcDecodable, Copy, Clone, HashStable_Generic)]
pub enum IntType { pub enum IntType {
SignedInt(ast::IntTy), SignedInt(ast::IntTy),
UnsignedInt(ast::UintTy) UnsignedInt(ast::UintTy)

View file

@ -19,6 +19,8 @@
#![recursion_limit="256"] #![recursion_limit="256"]
#[macro_use] extern crate rustc_macros;
pub use errors; pub use errors;
use rustc_data_structures::sync::Lock; use rustc_data_structures::sync::Lock;
use rustc_index::bit_set::GrowableBitSet; use rustc_index::bit_set::GrowableBitSet;