@@ -684,26 +684,11 @@ where
684684impl_stable_traits_for_trivial_type ! ( :: std:: path:: Path ) ;
685685impl_stable_traits_for_trivial_type ! ( :: std:: path:: PathBuf ) ;
686686
687- impl < K , V , R , HCX > HashStable < HCX > for :: std:: collections:: HashMap < K , V , R >
688- where
689- K : ToStableHashKey < HCX > + Eq ,
690- V : HashStable < HCX > ,
691- R : BuildHasher ,
692- {
693- #[ inline]
694- fn hash_stable ( & self , hcx : & mut HCX , hasher : & mut StableHasher ) {
695- stable_hash_reduce ( hcx, hasher, self . iter ( ) , self . len ( ) , |hasher, hcx, ( key, value) | {
696- let key = key. to_stable_hash_key ( hcx) ;
697- key. hash_stable ( hcx, hasher) ;
698- value. hash_stable ( hcx, hasher) ;
699- } ) ;
700- }
701- }
702-
703- // It is not safe to implement HashStable for HashSet or any other collection type
687+ // It is not safe to implement HashStable for HashSet, HashMap or any other collection type
704688// with unstable but observable iteration order.
705689// See https://github.com/rust-lang/compiler-team/issues/533 for further information.
706690impl < V , HCX > !HashStable < HCX > for std:: collections:: HashSet < V > { }
691+ impl < K , V , HCX > !HashStable < HCX > for std:: collections:: HashMap < K , V > { }
707692
708693impl < K , V , HCX > HashStable < HCX > for :: std:: collections:: BTreeMap < K , V >
709694where
@@ -730,35 +715,6 @@ where
730715 }
731716}
732717
733- fn stable_hash_reduce < HCX , I , C , F > (
734- hcx : & mut HCX ,
735- hasher : & mut StableHasher ,
736- mut collection : C ,
737- length : usize ,
738- hash_function : F ,
739- ) where
740- C : Iterator < Item = I > ,
741- F : Fn ( & mut StableHasher , & mut HCX , I ) ,
742- {
743- length. hash_stable ( hcx, hasher) ;
744-
745- match length {
746- 1 => {
747- hash_function ( hasher, hcx, collection. next ( ) . unwrap ( ) ) ;
748- }
749- _ => {
750- let hash = collection
751- . map ( |value| {
752- let mut hasher = StableHasher :: new ( ) ;
753- hash_function ( & mut hasher, hcx, value) ;
754- hasher. finish :: < Hash128 > ( )
755- } )
756- . reduce ( |accum, value| accum. wrapping_add ( value) ) ;
757- hash. hash_stable ( hcx, hasher) ;
758- }
759- }
760- }
761-
762718/// Controls what data we do or do not hash.
763719/// Whenever a `HashStable` implementation caches its
764720/// result, it needs to include `HashingControls` as part
0 commit comments