From 9e5054498b181fc3984e266d1aa05f076dfea22f Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Thu, 4 Feb 2021 11:04:29 +0100 Subject: Add unit test to ensure that both parts of a DefPathHash depend on the defining crate's ID. --- compiler/rustc_span/src/def_id.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'compiler/rustc_span/src') diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index 7c02056105e..bd8c95fd661 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -159,6 +159,12 @@ impl DefPathHash { StableCrateId(self.0.as_value().0) } + /// Returns the crate-local part of the [DefPathHash]. + #[inline] + pub fn local_hash(&self) -> u64 { + self.0.as_value().1 + } + /// Builds a new [DefPathHash] with the given [StableCrateId] and /// `local_hash`, where `local_hash` must be unique within its crate. pub fn new(stable_crate_id: StableCrateId, local_hash: u64) -> DefPathHash { -- cgit 1.4.1-3-g733a5