@@ -532,7 +532,10 @@ impl SourceId {
532
532
url == CRATES_IO_INDEX || url == CRATES_IO_HTTP_INDEX || is_overridden_crates_io_url ( url)
533
533
}
534
534
535
- /// Hashes `self`.
535
+ /// Hashes `self` to be used in the name of some Cargo folders, so shouldn't vary.
536
+ ///
537
+ /// For git and url, `as_str` gives the serialisation of a url (which has a spec) and so
538
+ /// insulates against possible changes in how the url crate does hashing.
536
539
///
537
540
/// For paths, remove the workspace prefix so the same source will give the
538
541
/// same hash in different locations, helping reproducible builds.
@@ -550,7 +553,11 @@ impl SourceId {
550
553
return ;
551
554
}
552
555
}
553
- self . hash ( into)
556
+ self . inner . kind . hash ( into) ;
557
+ match self . inner . kind {
558
+ SourceKind :: Git ( _) => ( & self ) . inner . canonical_url . hash ( into) ,
559
+ _ => ( & self ) . inner . url . as_str ( ) . hash ( into) ,
560
+ }
554
561
}
555
562
556
563
pub fn full_eq ( self , other : SourceId ) -> bool {
@@ -665,9 +672,6 @@ impl fmt::Display for SourceId {
665
672
}
666
673
}
667
674
668
- /// The hash of `SourceId` is used in the name of some Cargo folders, so shouldn't
669
- /// vary. `as_str` gives the serialisation of a url (which has a spec) and so
670
- /// insulates against possible changes in how the url crate does hashing.
671
675
impl Hash for SourceId {
672
676
fn hash < S : hash:: Hasher > ( & self , into : & mut S ) {
673
677
self . inner . kind . hash ( into) ;
0 commit comments