Add unit test to ensure that both parts of a DefPathHash depend on the defining crate's ID.

This commit is contained in:
Michael Woerister 2021-02-04 11:04:29 +01:00
parent 97380e3b06
commit 9e5054498b
4 changed files with 54 additions and 3 deletions

View file

@ -58,8 +58,11 @@ impl DefPathTable {
// being used.
//
// See the documentation for DefPathHash for more information.
panic!("found DefPathHash collsion between {:?} and {:?}. \
Compilation cannot continue.", def_path1, def_path2);
panic!(
"found DefPathHash collsion between {:?} and {:?}. \
Compilation cannot continue.",
def_path1, def_path2
);
}
// Assert that all DefPathHashes correctly contain the local crate's
@ -138,7 +141,7 @@ pub struct DefKey {
}
impl DefKey {
fn compute_stable_hash(&self, parent: DefPathHash) -> DefPathHash {
pub(crate) fn compute_stable_hash(&self, parent: DefPathHash) -> DefPathHash {
let mut hasher = StableHasher::new();
parent.hash(&mut hasher);