about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2019-11-10 19:32:04 +0100
committerCamille GILLOT <gillot.camille@gmail.com>2019-11-22 20:01:48 +0100
commitedc5232a4d1234d26015cd053db53f5a82c94a9d (patch)
tree696d4b6226dc4681b198c5dbfd6e2ec877a53415
parent8c86a7994733db6d405e33404afa09c63c0bef4d (diff)
Retire impl_stable_hash_for.
-rw-r--r--src/librustc/ich/impls_syntax.rs7
-rw-r--r--src/librustc/macros.rs116
2 files changed, 6 insertions, 117 deletions
diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs
index aae175e9647..6e030562832 100644
--- a/src/librustc/ich/impls_syntax.rs
+++ b/src/librustc/ich/impls_syntax.rs
@@ -18,7 +18,12 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 
 impl<'ctx> rustc_target::StableHashingContextLike for StableHashingContext<'ctx> {}
 
-impl_stable_hash_for!(struct ::syntax::ast::Lifetime { id, ident });
+impl<'a> HashStable<StableHashingContext<'a>> for ast::Lifetime {
+    fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
+        self.id.hash_stable(hcx, hasher);
+        self.ident.hash_stable(hcx, hasher);
+    }
+}
 
 impl<'a> HashStable<StableHashingContext<'a>> for [ast::Attribute] {
     fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
diff --git a/src/librustc/macros.rs b/src/librustc/macros.rs
index 59612a0ee5c..2bda0c0bef0 100644
--- a/src/librustc/macros.rs
+++ b/src/librustc/macros.rs
@@ -1,5 +1,3 @@
-// ignore-tidy-linelength
-
 macro_rules! enum_from_u32 {
     ($(#[$attr:meta])* pub enum $name:ident {
         $($variant:ident = $e:expr,)*
@@ -52,120 +50,6 @@ macro_rules! span_bug {
     })
 }
 
-#[macro_export]
-macro_rules! __impl_stable_hash_field {
-    ($field:ident, $ctx:expr, $hasher:expr) => ($field.hash_stable($ctx, $hasher));
-    ($field:ident, $ctx:expr, $hasher:expr, _) => ({ let _ = $field; });
-    ($field:ident, $ctx:expr, $hasher:expr, $delegate:expr) => ($delegate.hash_stable($ctx, $hasher));
-}
-
-#[macro_export]
-macro_rules! impl_stable_hash_for {
-    // Enums
-    (enum $enum_name:path {
-        $( $variant:ident
-           // this incorrectly allows specifying both tuple-like and struct-like fields, as in `Variant(a,b){c,d}`,
-           // when it should be only one or the other
-           $( ( $($field:ident $(-> $delegate:tt)?),* ) )?
-           $( { $($named_field:ident $(-> $named_delegate:tt)?),* } )?
-        ),* $(,)?
-    }) => {
-        impl_stable_hash_for!(
-            impl<> for enum $enum_name [ $enum_name ] { $( $variant
-                $( ( $($field $(-> $delegate)?),* ) )?
-                $( { $($named_field $(-> $named_delegate)?),* } )?
-            ),* }
-        );
-    };
-    // We want to use the enum name both in the `impl ... for $enum_name` as well as for
-    // importing all the variants. Unfortunately it seems we have to take the name
-    // twice for this purpose
-    (impl<$($T:ident),* $(,)?>
-        for enum $enum_name:path
-        [ $enum_path:path ]
-    {
-        $( $variant:ident
-           // this incorrectly allows specifying both tuple-like and struct-like fields, as in `Variant(a,b){c,d}`,
-           // when it should be only one or the other
-           $( ( $($field:ident $(-> $delegate:tt)?),* ) )?
-           $( { $($named_field:ident $(-> $named_delegate:tt)?),* } )?
-        ),* $(,)?
-    }) => {
-        impl<$($T,)*>
-            ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>
-            for $enum_name
-            where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),*
-        {
-            #[inline]
-            fn hash_stable(&self,
-                           __ctx: &mut $crate::ich::StableHashingContext<'a>,
-                           __hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher) {
-                use $enum_path::*;
-                ::std::mem::discriminant(self).hash_stable(__ctx, __hasher);
-
-                match *self {
-                    $(
-                        $variant $( ( $(ref $field),* ) )? $( { $(ref $named_field),* } )? => {
-                            $($( __impl_stable_hash_field!($field, __ctx, __hasher $(, $delegate)?) );*)?
-                            $($( __impl_stable_hash_field!($named_field, __ctx, __hasher $(, $named_delegate)?) );*)?
-                        }
-                    )*
-                }
-            }
-        }
-    };
-    // Structs
-    (struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => {
-        impl_stable_hash_for!(
-            impl<> for struct $struct_name { $($field $(-> $delegate)?),* }
-        );
-    };
-    (impl<$($T:ident),* $(,)?> for struct $struct_name:path {
-        $($field:ident $(-> $delegate:tt)?),* $(,)?
-    }) => {
-        impl<$($T,)*>
-            ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>> for $struct_name
-            where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),*
-        {
-            #[inline]
-            fn hash_stable(&self,
-                           __ctx: &mut $crate::ich::StableHashingContext<'a>,
-                           __hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher) {
-                let $struct_name {
-                    $(ref $field),*
-                } = *self;
-
-                $( __impl_stable_hash_field!($field, __ctx, __hasher $(, $delegate)?) );*
-            }
-        }
-    };
-    // Tuple structs
-    // We cannot use normal parentheses here, the parser won't allow it
-    (tuple_struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),*  $(,)? }) => {
-        impl_stable_hash_for!(
-            impl<> for tuple_struct $struct_name { $($field $(-> $delegate)?),* }
-        );
-    };
-    (impl<$($T:ident),* $(,)?>
-     for tuple_struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),*  $(,)? }) => {
-        impl<$($T,)*>
-            ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>> for $struct_name
-            where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),*
-        {
-            #[inline]
-            fn hash_stable(&self,
-                           __ctx: &mut $crate::ich::StableHashingContext<'a>,
-                           __hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher) {
-                let $struct_name (
-                    $(ref $field),*
-                ) = *self;
-
-                $( __impl_stable_hash_field!($field, __ctx, __hasher $(, $delegate)?) );*
-            }
-        }
-    };
-}
-
 ///////////////////////////////////////////////////////////////////////////
 // Lift and TypeFoldable macros
 //