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_index",
"rustc_lexer",
"rustc_macros",
"scoped-tls",
"serialize",
"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 {
Bang,
Attr,
@ -124,22 +119,6 @@ for ::syntax::attr::StabilityLevel {
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 {
kind,
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!(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!(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] {
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_index = { path = "../librustc_index" }
rustc_lexer = { path = "../librustc_lexer" }
rustc_macros = { path = "../librustc_macros" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
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.
#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)]
#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
pub enum CaptureBy {
/// `move |x| y + x`.
Value,
@ -1339,7 +1339,7 @@ pub enum CaptureBy {
/// The movability of a generator / closure literal:
/// whether a generator contains self-references, causing it to be `!Unpin`.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
RustcEncodable, RustcDecodable, Debug, Copy)]
RustcEncodable, RustcDecodable, Debug, Copy, HashStable_Generic)]
pub enum Movability {
/// May contain self-references, `!Unpin`.
Static,
@ -1400,7 +1400,7 @@ impl MacroDef {
}
// 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 {
/// A regular string, like `"foo"`.
Cooked,
@ -1451,7 +1451,7 @@ impl StrLit {
// Clippy uses Hash and PartialEq
/// 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 {
/// e.g. `42_i32`.
Signed(IntTy),
@ -1462,7 +1462,7 @@ pub enum LitIntType {
}
/// 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 {
/// A float literal with a suffix (`1f32` or `1E10f32`).
Suffixed(FloatTy),
@ -1609,7 +1609,8 @@ pub enum ImplItemKind {
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 {
F32,
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 {
Isize,
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 {
Usize,
U8,
@ -1863,7 +1866,7 @@ pub enum TraitObjectSyntax {
/// Inline assembly dialect.
///
/// 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 {
Att,
Intel,
@ -2021,14 +2024,14 @@ impl FnDecl {
}
/// 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 {
Yes,
No,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
RustcEncodable, RustcDecodable, Debug)]
RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
pub enum Unsafety {
Unsafe,
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 {
Const,
NotConst,
@ -2093,13 +2096,13 @@ pub enum Constness {
/// Item defaultness.
/// 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 {
Default,
Final,
}
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable_Generic)]
pub enum ImplPolarity {
/// `impl Trait for Type`
Positive,
@ -2233,7 +2236,7 @@ impl UseTree {
/// Distinguishes between `Attribute`s that decorate items and Attributes that
/// are contained as statements within items. These two cases need to be
/// distinguished for pretty-printing.
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy, HashStable_Generic)]
pub enum AttrStyle {
Outer,
Inner,

View File

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

View File

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