1 // This is here because `rustc_session` wants to refer to it,
2 // and so does `rustc_hir`, but `rustc_hir` shouldn't refer to `rustc_session`.
4 use rustc_data_structures::fingerprint::Fingerprint;
5 use rustc_data_structures::{base_n, impl_stable_hash_via_hash};
9 /// Hash value constructed out of all the `-C metadata` arguments passed to the
10 /// compiler. Together with the crate-name forms a unique global identifier for
12 #[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy, Encodable, Decodable)]
13 pub struct CrateDisambiguator(Fingerprint);
15 impl CrateDisambiguator {
16 pub fn to_fingerprint(self) -> Fingerprint {
21 impl fmt::Display for CrateDisambiguator {
22 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
23 let (a, b) = self.0.as_value();
24 let as_u128 = a as u128 | ((b as u128) << 64);
25 f.write_str(&base_n::encode(as_u128, base_n::CASE_INSENSITIVE))
29 impl From<Fingerprint> for CrateDisambiguator {
30 fn from(fingerprint: Fingerprint) -> CrateDisambiguator {
31 CrateDisambiguator(fingerprint)
35 impl_stable_hash_via_hash!(CrateDisambiguator);