Skip to content

Commit 2312ff1

Browse files
committedJun 7, 2021
Auto merge of #85891 - bjorn3:revert_merge_crate_disambiguator, r=Mark-Simulacrum
Revert "Merge CrateDisambiguator into StableCrateId" This reverts #85804
2 parents 022720b + 8176ab8 commit 2312ff1

File tree

69 files changed

+307
-224
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+307
-224
lines changed
 

‎compiler/rustc_hir/src/definitions.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use rustc_data_structures::fx::FxHashMap;
1414
use rustc_data_structures::stable_hasher::StableHasher;
1515
use rustc_data_structures::unhash::UnhashMap;
1616
use rustc_index::vec::IndexVec;
17+
use rustc_span::crate_disambiguator::CrateDisambiguator;
1718
use rustc_span::hygiene::ExpnId;
1819
use rustc_span::symbol::{kw, sym, Symbol};
1920

@@ -338,7 +339,7 @@ impl Definitions {
338339
}
339340

340341
/// Adds a root definition (no parent) and a few other reserved definitions.
341-
pub fn new(stable_crate_id: StableCrateId) -> Definitions {
342+
pub fn new(crate_name: &str, crate_disambiguator: CrateDisambiguator) -> Definitions {
342343
let key = DefKey {
343344
parent: None,
344345
disambiguated_data: DisambiguatedDefPathData {
@@ -347,6 +348,7 @@ impl Definitions {
347348
},
348349
};
349350

351+
let stable_crate_id = StableCrateId::new(crate_name, crate_disambiguator);
350352
let parent_hash = DefPathHash::new(stable_crate_id, 0);
351353
let def_path_hash = key.compute_stable_hash(parent_hash);
352354

‎compiler/rustc_hir/src/tests.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use crate::definitions::{DefKey, DefPathData, DisambiguatedDefPathData};
2+
use rustc_data_structures::fingerprint::Fingerprint;
3+
use rustc_span::crate_disambiguator::CrateDisambiguator;
24
use rustc_span::def_id::{DefPathHash, StableCrateId};
35

46
#[test]
@@ -11,16 +13,17 @@ fn def_path_hash_depends_on_crate_id() {
1113
// the crate by changing the crate disambiguator (e.g. via bumping the
1214
// crate's version number).
1315

14-
let id0 = StableCrateId::new("foo", false, vec!["1".to_string()]);
15-
let id1 = StableCrateId::new("foo", false, vec!["2".to_string()]);
16+
let d0 = CrateDisambiguator::from(Fingerprint::new(12, 34));
17+
let d1 = CrateDisambiguator::from(Fingerprint::new(56, 78));
1618

17-
let h0 = mk_test_hash(id0);
18-
let h1 = mk_test_hash(id1);
19+
let h0 = mk_test_hash("foo", d0);
20+
let h1 = mk_test_hash("foo", d1);
1921

2022
assert_ne!(h0.stable_crate_id(), h1.stable_crate_id());
2123
assert_ne!(h0.local_hash(), h1.local_hash());
2224

23-
fn mk_test_hash(stable_crate_id: StableCrateId) -> DefPathHash {
25+
fn mk_test_hash(crate_name: &str, crate_disambiguator: CrateDisambiguator) -> DefPathHash {
26+
let stable_crate_id = StableCrateId::new(crate_name, crate_disambiguator);
2427
let parent_hash = DefPathHash::new(stable_crate_id, 0);
2528

2629
let key = DefKey {

0 commit comments

Comments
 (0)