Auto merge of #86143 - bjorn3:revert_revert_merge_crate_disambiguator, r=michaelwoerister
Reland "Merge CrateDisambiguator into StableCrateId" Reverts https://github.com/rust-lang/rust/pull/85891 as this revert of #85804 made perf even worse. r? `@Mark-Simulacrum`
This commit is contained in:
commit
d04ec47358
67 changed files with 227 additions and 298 deletions
|
@ -12,7 +12,6 @@ use rustc_data_structures::fx::FxHashMap;
|
|||
use rustc_data_structures::stable_hasher::StableHasher;
|
||||
use rustc_data_structures::unhash::UnhashMap;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_span::crate_disambiguator::CrateDisambiguator;
|
||||
use rustc_span::hygiene::ExpnId;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
|
||||
|
@ -325,7 +324,7 @@ impl Definitions {
|
|||
}
|
||||
|
||||
/// Adds a root definition (no parent) and a few other reserved definitions.
|
||||
pub fn new(crate_name: &str, crate_disambiguator: CrateDisambiguator) -> Definitions {
|
||||
pub fn new(stable_crate_id: StableCrateId) -> Definitions {
|
||||
let key = DefKey {
|
||||
parent: None,
|
||||
disambiguated_data: DisambiguatedDefPathData {
|
||||
|
@ -334,7 +333,6 @@ impl Definitions {
|
|||
},
|
||||
};
|
||||
|
||||
let stable_crate_id = StableCrateId::new(crate_name, crate_disambiguator);
|
||||
let parent_hash = DefPathHash::new(stable_crate_id, 0);
|
||||
let def_path_hash = key.compute_stable_hash(parent_hash);
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
use crate::definitions::{DefKey, DefPathData, DisambiguatedDefPathData};
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_span::crate_disambiguator::CrateDisambiguator;
|
||||
use rustc_span::def_id::{DefPathHash, StableCrateId};
|
||||
|
||||
#[test]
|
||||
|
@ -13,17 +11,16 @@ fn def_path_hash_depends_on_crate_id() {
|
|||
// the crate by changing the crate disambiguator (e.g. via bumping the
|
||||
// crate's version number).
|
||||
|
||||
let d0 = CrateDisambiguator::from(Fingerprint::new(12, 34));
|
||||
let d1 = CrateDisambiguator::from(Fingerprint::new(56, 78));
|
||||
let id0 = StableCrateId::new("foo", false, vec!["1".to_string()]);
|
||||
let id1 = StableCrateId::new("foo", false, vec!["2".to_string()]);
|
||||
|
||||
let h0 = mk_test_hash("foo", d0);
|
||||
let h1 = mk_test_hash("foo", d1);
|
||||
let h0 = mk_test_hash(id0);
|
||||
let h1 = mk_test_hash(id1);
|
||||
|
||||
assert_ne!(h0.stable_crate_id(), h1.stable_crate_id());
|
||||
assert_ne!(h0.local_hash(), h1.local_hash());
|
||||
|
||||
fn mk_test_hash(crate_name: &str, crate_disambiguator: CrateDisambiguator) -> DefPathHash {
|
||||
let stable_crate_id = StableCrateId::new(crate_name, crate_disambiguator);
|
||||
fn mk_test_hash(stable_crate_id: StableCrateId) -> DefPathHash {
|
||||
let parent_hash = DefPathHash::new(stable_crate_id, 0);
|
||||
|
||||
let key = DefKey {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue