Store hashes in special types so they aren't accidentally encoded as numbers
This commit is contained in:
parent
de96f3d873
commit
0445fbdd83
38 changed files with 274 additions and 138 deletions
|
@ -9,7 +9,7 @@ use crate::def_id::{CrateNum, DefIndex, LocalDefId, StableCrateId, CRATE_DEF_IND
|
|||
use crate::def_path_hash_map::DefPathHashMap;
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::stable_hasher::StableHasher;
|
||||
use rustc_data_structures::stable_hasher::{Hash64, StableHasher};
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
|
||||
|
@ -130,7 +130,7 @@ impl DefKey {
|
|||
|
||||
disambiguator.hash(&mut hasher);
|
||||
|
||||
let local_hash: u64 = hasher.finish();
|
||||
let local_hash = hasher.finish();
|
||||
|
||||
// Construct the new DefPathHash, making sure that the `crate_id`
|
||||
// portion of the hash is properly copied from the parent. This way the
|
||||
|
@ -325,7 +325,7 @@ impl Definitions {
|
|||
},
|
||||
};
|
||||
|
||||
let parent_hash = DefPathHash::new(stable_crate_id, 0);
|
||||
let parent_hash = DefPathHash::new(stable_crate_id, Hash64::ZERO);
|
||||
let def_path_hash = key.compute_stable_hash(parent_hash);
|
||||
|
||||
// Create the root definition.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::definitions::{DefKey, DefPathData, DisambiguatedDefPathData};
|
||||
use rustc_data_structures::stable_hasher::Hash64;
|
||||
use rustc_span::def_id::{DefPathHash, StableCrateId};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::{create_session_if_not_set_then, Symbol};
|
||||
|
@ -24,7 +25,7 @@ fn def_path_hash_depends_on_crate_id() {
|
|||
assert_ne!(h0.local_hash(), h1.local_hash());
|
||||
|
||||
fn mk_test_hash(stable_crate_id: StableCrateId) -> DefPathHash {
|
||||
let parent_hash = DefPathHash::new(stable_crate_id, 0);
|
||||
let parent_hash = DefPathHash::new(stable_crate_id, Hash64::ZERO);
|
||||
|
||||
let key = DefKey {
|
||||
parent: None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue