Skip to content

Commit edc5232

Browse files
committed
Retire impl_stable_hash_for.
1 parent 8c86a79 commit edc5232

File tree

2 files changed

+6
-117
lines changed

2 files changed

+6
-117
lines changed

src/librustc/ich/impls_syntax.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1818

1919
impl<'ctx> rustc_target::StableHashingContextLike for StableHashingContext<'ctx> {}
2020

21-
impl_stable_hash_for!(struct ::syntax::ast::Lifetime { id, ident });
21+
impl<'a> HashStable<StableHashingContext<'a>> for ast::Lifetime {
22+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
23+
self.id.hash_stable(hcx, hasher);
24+
self.ident.hash_stable(hcx, hasher);
25+
}
26+
}
2227

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

src/librustc/macros.rs

-116
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore-tidy-linelength
2-
31
macro_rules! enum_from_u32 {
42
($(#[$attr:meta])* pub enum $name:ident {
53
$($variant:ident = $e:expr,)*
@@ -52,120 +50,6 @@ macro_rules! span_bug {
5250
})
5351
}
5452

55-
#[macro_export]
56-
macro_rules! __impl_stable_hash_field {
57-
($field:ident, $ctx:expr, $hasher:expr) => ($field.hash_stable($ctx, $hasher));
58-
($field:ident, $ctx:expr, $hasher:expr, _) => ({ let _ = $field; });
59-
($field:ident, $ctx:expr, $hasher:expr, $delegate:expr) => ($delegate.hash_stable($ctx, $hasher));
60-
}
61-
62-
#[macro_export]
63-
macro_rules! impl_stable_hash_for {
64-
// Enums
65-
(enum $enum_name:path {
66-
$( $variant:ident
67-
// this incorrectly allows specifying both tuple-like and struct-like fields, as in `Variant(a,b){c,d}`,
68-
// when it should be only one or the other
69-
$( ( $($field:ident $(-> $delegate:tt)?),* ) )?
70-
$( { $($named_field:ident $(-> $named_delegate:tt)?),* } )?
71-
),* $(,)?
72-
}) => {
73-
impl_stable_hash_for!(
74-
impl<> for enum $enum_name [ $enum_name ] { $( $variant
75-
$( ( $($field $(-> $delegate)?),* ) )?
76-
$( { $($named_field $(-> $named_delegate)?),* } )?
77-
),* }
78-
);
79-
};
80-
// We want to use the enum name both in the `impl ... for $enum_name` as well as for
81-
// importing all the variants. Unfortunately it seems we have to take the name
82-
// twice for this purpose
83-
(impl<$($T:ident),* $(,)?>
84-
for enum $enum_name:path
85-
[ $enum_path:path ]
86-
{
87-
$( $variant:ident
88-
// this incorrectly allows specifying both tuple-like and struct-like fields, as in `Variant(a,b){c,d}`,
89-
// when it should be only one or the other
90-
$( ( $($field:ident $(-> $delegate:tt)?),* ) )?
91-
$( { $($named_field:ident $(-> $named_delegate:tt)?),* } )?
92-
),* $(,)?
93-
}) => {
94-
impl<$($T,)*>
95-
::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>
96-
for $enum_name
97-
where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),*
98-
{
99-
#[inline]
100-
fn hash_stable(&self,
101-
__ctx: &mut $crate::ich::StableHashingContext<'a>,
102-
__hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher) {
103-
use $enum_path::*;
104-
::std::mem::discriminant(self).hash_stable(__ctx, __hasher);
105-
106-
match *self {
107-
$(
108-
$variant $( ( $(ref $field),* ) )? $( { $(ref $named_field),* } )? => {
109-
$($( __impl_stable_hash_field!($field, __ctx, __hasher $(, $delegate)?) );*)?
110-
$($( __impl_stable_hash_field!($named_field, __ctx, __hasher $(, $named_delegate)?) );*)?
111-
}
112-
)*
113-
}
114-
}
115-
}
116-
};
117-
// Structs
118-
(struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => {
119-
impl_stable_hash_for!(
120-
impl<> for struct $struct_name { $($field $(-> $delegate)?),* }
121-
);
122-
};
123-
(impl<$($T:ident),* $(,)?> for struct $struct_name:path {
124-
$($field:ident $(-> $delegate:tt)?),* $(,)?
125-
}) => {
126-
impl<$($T,)*>
127-
::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>> for $struct_name
128-
where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),*
129-
{
130-
#[inline]
131-
fn hash_stable(&self,
132-
__ctx: &mut $crate::ich::StableHashingContext<'a>,
133-
__hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher) {
134-
let $struct_name {
135-
$(ref $field),*
136-
} = *self;
137-
138-
$( __impl_stable_hash_field!($field, __ctx, __hasher $(, $delegate)?) );*
139-
}
140-
}
141-
};
142-
// Tuple structs
143-
// We cannot use normal parentheses here, the parser won't allow it
144-
(tuple_struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => {
145-
impl_stable_hash_for!(
146-
impl<> for tuple_struct $struct_name { $($field $(-> $delegate)?),* }
147-
);
148-
};
149-
(impl<$($T:ident),* $(,)?>
150-
for tuple_struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => {
151-
impl<$($T,)*>
152-
::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>> for $struct_name
153-
where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),*
154-
{
155-
#[inline]
156-
fn hash_stable(&self,
157-
__ctx: &mut $crate::ich::StableHashingContext<'a>,
158-
__hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher) {
159-
let $struct_name (
160-
$(ref $field),*
161-
) = *self;
162-
163-
$( __impl_stable_hash_field!($field, __ctx, __hasher $(, $delegate)?) );*
164-
}
165-
}
166-
};
167-
}
168-
16953
///////////////////////////////////////////////////////////////////////////
17054
// Lift and TypeFoldable macros
17155
//

0 commit comments

Comments
 (0)