Skip to content

Commit c2e1658

Browse files
committed
Use proc_macro for HashStable derive in libsyntax.
1 parent 5b0e702 commit c2e1658

File tree

6 files changed

+23
-49
lines changed

6 files changed

+23
-49
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4411,6 +4411,7 @@ dependencies = [
44114411
"rustc_errors",
44124412
"rustc_index",
44134413
"rustc_lexer",
4414+
"rustc_macros",
44144415
"scoped-tls",
44154416
"serialize",
44164417
"smallvec 1.0.0",

src/librustc/ich/impls_syntax.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for ast::Name {
5555
}
5656
}
5757

58-
impl_stable_hash_for!(enum ::syntax::ast::AsmDialect {
59-
Att,
60-
Intel
61-
});
62-
6358
impl_stable_hash_for!(enum ::syntax_pos::hygiene::MacroKind {
6459
Bang,
6560
Attr,
@@ -124,22 +119,6 @@ for ::syntax::attr::StabilityLevel {
124119

125120
impl_stable_hash_for!(struct ::syntax::attr::RustcDeprecation { since, reason, suggestion });
126121

127-
impl_stable_hash_for!(enum ::syntax::attr::IntType {
128-
SignedInt(int_ty),
129-
UnsignedInt(uint_ty)
130-
});
131-
132-
impl_stable_hash_for!(enum ::syntax::ast::LitIntType {
133-
Signed(int_ty),
134-
Unsigned(int_ty),
135-
Unsuffixed
136-
});
137-
138-
impl_stable_hash_for!(enum ::syntax::ast::LitFloatType {
139-
Suffixed(float_ty),
140-
Unsuffixed
141-
});
142-
143122
impl_stable_hash_for!(struct ::syntax::ast::Lit {
144123
kind,
145124
token,
@@ -159,19 +138,7 @@ impl_stable_hash_for!(enum ::syntax::ast::LitKind {
159138

160139
impl_stable_hash_for_spanned!(::syntax::ast::LitKind);
161140

162-
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 });
163-
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 });
164-
impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
165-
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
166-
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });
167-
impl_stable_hash_for!(enum ::syntax::ast::Defaultness { Default, Final });
168141
impl_stable_hash_for!(struct ::syntax::ast::Lifetime { id, ident });
169-
impl_stable_hash_for!(enum ::syntax::ast::StrStyle { Cooked, Raw(pounds) });
170-
impl_stable_hash_for!(enum ::syntax::ast::AttrStyle { Outer, Inner });
171-
impl_stable_hash_for!(enum ::syntax::ast::Movability { Static, Movable });
172-
impl_stable_hash_for!(enum ::syntax::ast::CaptureBy { Value, Ref });
173-
impl_stable_hash_for!(enum ::syntax::ast::IsAuto { Yes, No });
174-
impl_stable_hash_for!(enum ::syntax::ast::ImplPolarity { Positive, Negative });
175142

176143
impl<'a> HashStable<StableHashingContext<'a>> for [ast::Attribute] {
177144
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {

src/libsyntax/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ errors = { path = "../librustc_errors", package = "rustc_errors" }
2020
rustc_data_structures = { path = "../librustc_data_structures" }
2121
rustc_index = { path = "../librustc_index" }
2222
rustc_lexer = { path = "../librustc_lexer" }
23+
rustc_macros = { path = "../librustc_macros" }
2324
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
2425
rustc_error_codes = { path = "../librustc_error_codes" }

src/libsyntax/ast.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ pub struct QSelf {
13281328
}
13291329

13301330
/// A capture clause used in closures and `async` blocks.
1331-
#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)]
1331+
#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
13321332
pub enum CaptureBy {
13331333
/// `move |x| y + x`.
13341334
Value,
@@ -1339,7 +1339,7 @@ pub enum CaptureBy {
13391339
/// The movability of a generator / closure literal:
13401340
/// whether a generator contains self-references, causing it to be `!Unpin`.
13411341
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
1342-
RustcEncodable, RustcDecodable, Debug, Copy)]
1342+
RustcEncodable, RustcDecodable, Debug, Copy, HashStable_Generic)]
13431343
pub enum Movability {
13441344
/// May contain self-references, `!Unpin`.
13451345
Static,
@@ -1400,7 +1400,7 @@ impl MacroDef {
14001400
}
14011401

14021402
// Clippy uses Hash and PartialEq
1403-
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy, Hash, PartialEq)]
1403+
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy, Hash, PartialEq, HashStable_Generic)]
14041404
pub enum StrStyle {
14051405
/// A regular string, like `"foo"`.
14061406
Cooked,
@@ -1451,7 +1451,7 @@ impl StrLit {
14511451

14521452
// Clippy uses Hash and PartialEq
14531453
/// Type of the integer literal based on provided suffix.
1454-
#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq)]
1454+
#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq, HashStable_Generic)]
14551455
pub enum LitIntType {
14561456
/// e.g. `42_i32`.
14571457
Signed(IntTy),
@@ -1462,7 +1462,7 @@ pub enum LitIntType {
14621462
}
14631463

14641464
/// Type of the float literal based on provided suffix.
1465-
#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq)]
1465+
#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq, HashStable_Generic)]
14661466
pub enum LitFloatType {
14671467
/// A float literal with a suffix (`1f32` or `1E10f32`).
14681468
Suffixed(FloatTy),
@@ -1609,7 +1609,8 @@ pub enum ImplItemKind {
16091609
Macro(Mac),
16101610
}
16111611

1612-
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug)]
1612+
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable_Generic,
1613+
RustcEncodable, RustcDecodable, Debug)]
16131614
pub enum FloatTy {
16141615
F32,
16151616
F64,
@@ -1638,7 +1639,8 @@ impl FloatTy {
16381639
}
16391640
}
16401641

1641-
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug)]
1642+
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable_Generic,
1643+
RustcEncodable, RustcDecodable, Debug)]
16421644
pub enum IntTy {
16431645
Isize,
16441646
I8,
@@ -1690,7 +1692,8 @@ impl IntTy {
16901692
}
16911693
}
16921694

1693-
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Copy, Debug)]
1695+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable_Generic,
1696+
RustcEncodable, RustcDecodable, Copy, Debug)]
16941697
pub enum UintTy {
16951698
Usize,
16961699
U8,
@@ -1863,7 +1866,7 @@ pub enum TraitObjectSyntax {
18631866
/// Inline assembly dialect.
18641867
///
18651868
/// E.g., `"intel"` as in `asm!("mov eax, 2" : "={eax}"(result) : : : "intel")`.
1866-
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
1869+
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy, HashStable_Generic)]
18671870
pub enum AsmDialect {
18681871
Att,
18691872
Intel,
@@ -2021,14 +2024,14 @@ impl FnDecl {
20212024
}
20222025

20232026
/// Is the trait definition an auto trait?
2024-
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
2027+
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
20252028
pub enum IsAuto {
20262029
Yes,
20272030
No,
20282031
}
20292032

20302033
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
2031-
RustcEncodable, RustcDecodable, Debug)]
2034+
RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
20322035
pub enum Unsafety {
20332036
Unsafe,
20342037
Normal,
@@ -2085,21 +2088,21 @@ impl IsAsync {
20852088
}
20862089
}
20872090

2088-
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
2091+
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
20892092
pub enum Constness {
20902093
Const,
20912094
NotConst,
20922095
}
20932096

20942097
/// Item defaultness.
20952098
/// For details see the [RFC #2532](https://github.com/rust-lang/rfcs/pull/2532).
2096-
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
2099+
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
20972100
pub enum Defaultness {
20982101
Default,
20992102
Final,
21002103
}
21012104

2102-
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
2105+
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable_Generic)]
21032106
pub enum ImplPolarity {
21042107
/// `impl Trait for Type`
21052108
Positive,
@@ -2233,7 +2236,7 @@ impl UseTree {
22332236
/// Distinguishes between `Attribute`s that decorate items and Attributes that
22342237
/// are contained as statements within items. These two cases need to be
22352238
/// distinguished for pretty-printing.
2236-
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
2239+
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy, HashStable_Generic)]
22372240
pub enum AttrStyle {
22382241
Outer,
22392242
Inner,

src/libsyntax/attr/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ pub enum ReprAttr {
763763
ReprAlign(u32),
764764
}
765765

766-
#[derive(Eq, PartialEq, Debug, RustcEncodable, RustcDecodable, Copy, Clone)]
766+
#[derive(Eq, PartialEq, Debug, RustcEncodable, RustcDecodable, Copy, Clone, HashStable_Generic)]
767767
pub enum IntType {
768768
SignedInt(ast::IntTy),
769769
UnsignedInt(ast::UintTy)

src/libsyntax/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#![recursion_limit="256"]
2121

22+
#[macro_use] extern crate rustc_macros;
23+
2224
pub use errors;
2325
use rustc_data_structures::sync::Lock;
2426
use rustc_index::bit_set::GrowableBitSet;

0 commit comments

Comments
 (0)