@@ -681,31 +681,6 @@ impl Ord for SourceKind {
681
681
}
682
682
}
683
683
684
- // This is a test that the hash of the `SourceId` for crates.io is a well-known
685
- // value.
686
- //
687
- // Note that the hash value matches what the crates.io source id has hashed
688
- // since long before Rust 1.30. We strive to keep this value the same across
689
- // versions of Cargo because changing it means that users will need to
690
- // redownload the index and all crates they use when using a new Cargo version.
691
- //
692
- // This isn't to say that this hash can *never* change, only that when changing
693
- // this it should be explicitly done. If this hash changes accidentally and
694
- // you're able to restore the hash to its original value, please do so!
695
- // Otherwise please just leave a comment in your PR as to why the hash value is
696
- // changing and why the old value can't be easily preserved.
697
- //
698
- // The hash value depends on endianness and bit-width, so we only run this test on
699
- // little-endian 64-bit CPUs (such as x86-64 and ARM64) where it matches the
700
- // well-known value.
701
- #[ test]
702
- #[ cfg( all( target_endian = "little" , target_pointer_width = "64" ) ) ]
703
- fn test_cratesio_hash ( ) {
704
- let config = Config :: default ( ) . unwrap ( ) ;
705
- let crates_io = SourceId :: crates_io ( & config) . unwrap ( ) ;
706
- assert_eq ! ( crate :: util:: hex:: short_hash( & crates_io) , "1ecc6299db9ec823" ) ;
707
- }
708
-
709
684
/// A `Display`able view into a `SourceId` that will write it as a url
710
685
pub struct SourceIdAsUrl < ' a > {
711
686
inner : & ' a SourceIdInner ,
@@ -792,7 +767,7 @@ impl<'a> fmt::Display for PrettyRef<'a> {
792
767
#[ cfg( test) ]
793
768
mod tests {
794
769
use super :: { GitReference , SourceId , SourceKind } ;
795
- use crate :: util:: IntoUrl ;
770
+ use crate :: util:: { Config , IntoUrl } ;
796
771
797
772
#[ test]
798
773
fn github_sources_equal ( ) {
@@ -809,4 +784,29 @@ mod tests {
809
784
let s3 = SourceId :: new ( foo, loc, None ) . unwrap ( ) ;
810
785
assert_ne ! ( s1, s3) ;
811
786
}
787
+
788
+ // This is a test that the hash of the `SourceId` for crates.io is a well-known
789
+ // value.
790
+ //
791
+ // Note that the hash value matches what the crates.io source id has hashed
792
+ // since long before Rust 1.30. We strive to keep this value the same across
793
+ // versions of Cargo because changing it means that users will need to
794
+ // redownload the index and all crates they use when using a new Cargo version.
795
+ //
796
+ // This isn't to say that this hash can *never* change, only that when changing
797
+ // this it should be explicitly done. If this hash changes accidentally and
798
+ // you're able to restore the hash to its original value, please do so!
799
+ // Otherwise please just leave a comment in your PR as to why the hash value is
800
+ // changing and why the old value can't be easily preserved.
801
+ //
802
+ // The hash value depends on endianness and bit-width, so we only run this test on
803
+ // little-endian 64-bit CPUs (such as x86-64 and ARM64) where it matches the
804
+ // well-known value.
805
+ #[ test]
806
+ #[ cfg( all( target_endian = "little" , target_pointer_width = "64" ) ) ]
807
+ fn test_cratesio_hash ( ) {
808
+ let config = Config :: default ( ) . unwrap ( ) ;
809
+ let crates_io = SourceId :: crates_io ( & config) . unwrap ( ) ;
810
+ assert_eq ! ( crate :: util:: hex:: short_hash( & crates_io) , "1ecc6299db9ec823" ) ;
811
+ }
812
812
}
0 commit comments