@@ -762,7 +762,7 @@ mod tests {
762762 // value.
763763 //
764764 // Note that the hash value matches what the crates.io source id has hashed
765- // since long before Rust 1.30 . We strive to keep this value the same across
765+ // since Rust 1.84.0 . We strive to keep this value the same across
766766 // versions of Cargo because changing it means that users will need to
767767 // redownload the index and all crates they use when using a new Cargo version.
768768 //
@@ -771,6 +771,11 @@ mod tests {
771771 // you're able to restore the hash to its original value, please do so!
772772 // Otherwise please just leave a comment in your PR as to why the hash value is
773773 // changing and why the old value can't be easily preserved.
774+ // If it takes an ugly hack to restore it,
775+ // then leave a link here so we can remove the hack next time we change the hash.
776+ //
777+ // Hacks to remove next time the hash changes:
778+ // - (fill in your code here)
774779 //
775780 // The hash value should be stable across platforms, and doesn't depend on
776781 // endianness and bit-width. One caveat is that absolute paths on Windows
@@ -782,6 +787,11 @@ mod tests {
782787 use std:: hash:: Hasher ;
783788 use std:: path:: Path ;
784789
790+ use snapbox:: assert_data_eq;
791+ use snapbox:: str;
792+ use snapbox:: IntoData as _;
793+
794+ use crate :: util:: hex:: short_hash;
785795 use crate :: util:: StableHasher ;
786796
787797 #[ cfg( not( windows) ) ]
@@ -792,68 +802,68 @@ mod tests {
792802 let gen_hash = |source_id : SourceId | {
793803 let mut hasher = StableHasher :: new ( ) ;
794804 source_id. stable_hash ( ws_root, & mut hasher) ;
795- Hasher :: finish ( & hasher)
805+ Hasher :: finish ( & hasher) . to_string ( )
796806 } ;
797807
798808 let source_id = SourceId :: crates_io ( & GlobalContext :: default ( ) . unwrap ( ) ) . unwrap ( ) ;
799- assert_eq ! ( gen_hash( source_id) , 7062945687441624357 ) ;
800- assert_eq ! ( crate :: util :: hex :: short_hash( & source_id) , "25cdd57fae9f0462" ) ;
809+ assert_data_eq ! ( gen_hash( source_id) , str ! [ " 7062945687441624357" ] . raw ( ) ) ;
810+ assert_data_eq ! ( short_hash( & source_id) , str ! [ "25cdd57fae9f0462" ] . raw ( ) ) ;
801811
802812 let url = "https://my-crates.io" . into_url ( ) . unwrap ( ) ;
803813 let source_id = SourceId :: for_registry ( & url) . unwrap ( ) ;
804- assert_eq ! ( gen_hash( source_id) , 8310250053664888498 ) ;
805- assert_eq ! ( crate :: util :: hex :: short_hash( & source_id) , "b2d65deb64f05373" ) ;
814+ assert_data_eq ! ( gen_hash( source_id) , str ! [ " 8310250053664888498" ] . raw ( ) ) ;
815+ assert_data_eq ! ( short_hash( & source_id) , str ! [ "b2d65deb64f05373" ] . raw ( ) ) ;
806816
807817 let url = "https://your-crates.io" . into_url ( ) . unwrap ( ) ;
808818 let source_id = SourceId :: for_alt_registry ( & url, "alt" ) . unwrap ( ) ;
809- assert_eq ! ( gen_hash( source_id) , 14149534903000258933 ) ;
810- assert_eq ! ( crate :: util :: hex :: short_hash( & source_id) , "755952de063f5dc4" ) ;
819+ assert_data_eq ! ( gen_hash( source_id) , str ! [ " 14149534903000258933" ] . raw ( ) ) ;
820+ assert_data_eq ! ( short_hash( & source_id) , str ! [ "755952de063f5dc4" ] . raw ( ) ) ;
811821
812822 let url = "sparse+https://my-crates.io" . into_url ( ) . unwrap ( ) ;
813823 let source_id = SourceId :: for_registry ( & url) . unwrap ( ) ;
814- assert_eq ! ( gen_hash( source_id) , 16249512552851930162 ) ;
815- assert_eq ! ( crate :: util :: hex :: short_hash( & source_id) , "327cfdbd92dd81e1" ) ;
824+ assert_data_eq ! ( gen_hash( source_id) , str ! [ " 16249512552851930162" ] . raw ( ) ) ;
825+ assert_data_eq ! ( short_hash( & source_id) , str ! [ "327cfdbd92dd81e1" ] . raw ( ) ) ;
816826
817827 let url = "sparse+https://your-crates.io" . into_url ( ) . unwrap ( ) ;
818828 let source_id = SourceId :: for_alt_registry ( & url, "alt" ) . unwrap ( ) ;
819- assert_eq ! ( gen_hash( source_id) , 6156697384053352292 ) ;
820- assert_eq ! ( crate :: util :: hex :: short_hash( & source_id) , "64a713b6a6fb7055" ) ;
829+ assert_data_eq ! ( gen_hash( source_id) , str ! [ " 6156697384053352292" ] . raw ( ) ) ;
830+ assert_data_eq ! ( short_hash( & source_id) , str ! [ "64a713b6a6fb7055" ] . raw ( ) ) ;
821831
822832 let url = "file:///tmp/ws/crate" . into_url ( ) . unwrap ( ) ;
823833 let source_id = SourceId :: for_git ( & url, GitReference :: DefaultBranch ) . unwrap ( ) ;
824- assert_eq ! ( gen_hash( source_id) , 473480029881867801 ) ;
825- assert_eq ! ( crate :: util :: hex :: short_hash( & source_id) , "199e591d94239206" ) ;
834+ assert_data_eq ! ( gen_hash( source_id) , str ! [ " 473480029881867801" ] . raw ( ) ) ;
835+ assert_data_eq ! ( short_hash( & source_id) , str ! [ "199e591d94239206" ] . raw ( ) ) ;
826836
827837 let path = & ws_root. join ( "crate" ) ;
828838 let source_id = SourceId :: for_local_registry ( path) . unwrap ( ) ;
829839 #[ cfg( not( windows) ) ]
830840 {
831- assert_eq ! ( gen_hash( source_id) , 11515846423845066584 ) ;
832- assert_eq ! ( crate :: util :: hex :: short_hash( & source_id) , "58d73c154f81d09f" ) ;
841+ assert_data_eq ! ( gen_hash( source_id) , str ! [ " 11515846423845066584" ] . raw ( ) ) ;
842+ assert_data_eq ! ( short_hash( & source_id) , str ! [ "58d73c154f81d09f" ] . raw ( ) ) ;
833843 }
834844 #[ cfg( windows) ]
835845 {
836- assert_eq ! ( gen_hash( source_id) , 6146331155906064276 ) ;
837- assert_eq ! ( crate :: util :: hex :: short_hash( & source_id) , "946fb2239f274c55" ) ;
846+ assert_data_eq ! ( gen_hash( source_id) , str ! [ " 6146331155906064276" ] . raw ( ) ) ;
847+ assert_data_eq ! ( short_hash( & source_id) , str ! [ "946fb2239f274c55" ] . raw ( ) ) ;
838848 }
839849
840850 let source_id = SourceId :: for_path ( path) . unwrap ( ) ;
841- assert_eq ! ( gen_hash( source_id) , 215644081443634269 ) ;
851+ assert_data_eq ! ( gen_hash( source_id) , str ! [ " 215644081443634269" ] . raw ( ) ) ;
842852 #[ cfg( not( windows) ) ]
843- assert_eq ! ( crate :: util :: hex :: short_hash( & source_id) , "64bace89c92b101f" ) ;
853+ assert_data_eq ! ( short_hash( & source_id) , str ! [ "64bace89c92b101f" ] . raw ( ) ) ;
844854 #[ cfg( windows) ]
845- assert_eq ! ( crate :: util :: hex :: short_hash( & source_id) , "01e1e6c391813fb6" ) ;
855+ assert_data_eq ! ( short_hash( & source_id) , str ! [ "01e1e6c391813fb6" ] . raw ( ) ) ;
846856
847857 let source_id = SourceId :: for_directory ( path) . unwrap ( ) ;
848858 #[ cfg( not( windows) ) ]
849859 {
850- assert_eq ! ( gen_hash( source_id) , 6127590343904940368 ) ;
851- assert_eq ! ( crate :: util :: hex :: short_hash( & source_id) , "505191d1f3920955" ) ;
860+ assert_data_eq ! ( gen_hash( source_id) , str ! [ " 6127590343904940368" ] . raw ( ) ) ;
861+ assert_data_eq ! ( short_hash( & source_id) , str ! [ "505191d1f3920955" ] . raw ( ) ) ;
852862 }
853863 #[ cfg( windows) ]
854864 {
855- assert_eq ! ( gen_hash( source_id) , 10423446877655960172 ) ;
856- assert_eq ! ( crate :: util :: hex :: short_hash( & source_id) , "6c8ad69db585a790" ) ;
865+ assert_data_eq ! ( gen_hash( source_id) , str ! [ " 10423446877655960172" ] . raw ( ) ) ;
866+ assert_data_eq ! ( short_hash( & source_id) , str ! [ "6c8ad69db585a790" ] . raw ( ) ) ;
857867 }
858868 }
859869
0 commit comments