Skip to content

Commit efcb695

Browse files
committed
Further HashStable_Generic derives.
1 parent 1dd5133 commit efcb695

File tree

4 files changed

+11
-53
lines changed

4 files changed

+11
-53
lines changed

src/librustc/ich/impls_syntax.rs

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ use crate::hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX};
1717
use smallvec::SmallVec;
1818
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1919

20-
impl_stable_hash_for!(enum ::syntax_pos::hygiene::MacroKind {
21-
Bang,
22-
Attr,
23-
Derive,
24-
});
25-
26-
2720
impl_stable_hash_for!(enum ::rustc_target::spec::abi::Abi {
2821
Cdecl,
2922
Stdcall,
@@ -47,57 +40,17 @@ impl_stable_hash_for!(enum ::rustc_target::spec::abi::Abi {
4740
Unadjusted
4841
});
4942

50-
impl_stable_hash_for!(struct ::syntax::attr::Deprecation { since, note });
51-
impl_stable_hash_for!(struct ::syntax::attr::Stability {
52-
level,
53-
feature,
54-
rustc_depr,
55-
promotable,
56-
allow_const_fn_ptr,
57-
const_stability
58-
});
59-
6043
impl_stable_hash_for!(enum ::syntax::edition::Edition {
6144
Edition2015,
6245
Edition2018,
6346
});
6447

65-
impl<'a> HashStable<StableHashingContext<'a>>
66-
for ::syntax::attr::StabilityLevel {
67-
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
68-
mem::discriminant(self).hash_stable(hcx, hasher);
69-
match *self {
70-
::syntax::attr::StabilityLevel::Unstable { ref reason, ref issue, ref is_soft } => {
71-
reason.hash_stable(hcx, hasher);
72-
issue.hash_stable(hcx, hasher);
73-
is_soft.hash_stable(hcx, hasher);
74-
}
75-
::syntax::attr::StabilityLevel::Stable { ref since } => {
76-
since.hash_stable(hcx, hasher);
77-
}
78-
}
79-
}
80-
}
81-
82-
impl_stable_hash_for!(struct ::syntax::attr::RustcDeprecation { since, reason, suggestion });
83-
8448
impl_stable_hash_for!(struct ::syntax::ast::Lit {
8549
kind,
8650
token,
8751
span
8852
});
8953

90-
impl_stable_hash_for!(enum ::syntax::ast::LitKind {
91-
Str(value, style),
92-
ByteStr(value),
93-
Byte(value),
94-
Char(value),
95-
Int(value, lit_int_type),
96-
Float(value, lit_float_type),
97-
Bool(value),
98-
Err(value)
99-
});
100-
10154
impl_stable_hash_for_spanned!(::syntax::ast::LitKind);
10255

10356
impl_stable_hash_for!(struct ::syntax::ast::Lifetime { id, ident });

src/libsyntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ pub enum LitFloatType {
14741474
///
14751475
/// E.g., `"foo"`, `42`, `12.34`, or `bool`.
14761476
// Clippy uses Hash and PartialEq
1477-
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq)]
1477+
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq, HashStable_Generic)]
14781478
pub enum LitKind {
14791479
/// A string literal (`"foo"`).
14801480
Str(Symbol, StrStyle),

src/libsyntax/attr/builtin.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ pub fn find_unwind_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> Op
141141
}
142142

143143
/// Represents the #[stable], #[unstable], #[rustc_{deprecated,const_unstable}] attributes.
144-
#[derive(RustcEncodable, RustcDecodable, Copy, Clone, Debug, PartialEq, Eq, Hash)]
144+
#[derive(RustcEncodable, RustcDecodable, Copy, Clone, Debug,
145+
PartialEq, Eq, Hash, HashStable_Generic)]
145146
pub struct Stability {
146147
pub level: StabilityLevel,
147148
pub feature: Symbol,
@@ -157,7 +158,8 @@ pub struct Stability {
157158
}
158159

159160
/// The available stability levels.
160-
#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Copy, Clone, Debug, Eq, Hash)]
161+
#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd,
162+
Copy, Clone, Debug, Eq, Hash, HashStable_Generic)]
161163
pub enum StabilityLevel {
162164
// Reason for the current stability level and the relevant rust-lang issue
163165
Unstable { reason: Option<Symbol>, issue: Option<NonZeroU32>, is_soft: bool },
@@ -181,7 +183,8 @@ impl StabilityLevel {
181183
}
182184
}
183185

184-
#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Copy, Clone, Debug, Eq, Hash)]
186+
#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd,
187+
Copy, Clone, Debug, Eq, Hash, HashStable_Generic)]
185188
pub struct RustcDeprecation {
186189
pub since: Symbol,
187190
pub reason: Symbol,
@@ -636,7 +639,7 @@ pub fn eval_condition<F>(cfg: &ast::MetaItem, sess: &ParseSess, eval: &mut F)
636639
}
637640
}
638641

639-
#[derive(RustcEncodable, RustcDecodable, Clone)]
642+
#[derive(RustcEncodable, RustcDecodable, Clone, HashStable_Generic)]
640643
pub struct Deprecation {
641644
pub since: Option<Symbol>,
642645
pub note: Option<Symbol>,

src/libsyntax_pos/hygiene.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use crate::{Span, DUMMY_SP};
3030
use crate::edition::Edition;
3131
use crate::symbol::{kw, sym, Symbol};
3232

33+
use rustc_macros::HashStable_Generic;
3334
use rustc_serialize::{Encodable, Decodable, Encoder, Decoder};
3435
use rustc_data_structures::fx::FxHashMap;
3536
use rustc_data_structures::sync::Lrc;
@@ -707,7 +708,8 @@ impl ExpnKind {
707708
}
708709

709710
/// The kind of macro invocation or definition.
710-
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
711+
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable,
712+
Hash, Debug, HashStable_Generic)]
711713
pub enum MacroKind {
712714
/// A bang macro `foo!()`.
713715
Bang,

0 commit comments

Comments
 (0)