Skip to content

Commit 5f73085

Browse files
Rename DefPathHashMap in rustc_metadata so its name does not clash with DefPathHashMap in rustc_hir.
1 parent 021c052 commit 5f73085

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ mod cstore_impl;
5555
crate struct MetadataBlob(Lrc<MetadataRef>);
5656

5757
// This is needed so we can create an OwningRef into the blob.
58-
// The data behind a `MetadataBlob` has a stable address because it
58+
// The data behind a `MetadataBlob` has a stable address because it is
5959
// contained within an Rc/Arc.
6060
unsafe impl rustc_data_structures::owning_ref::StableAddress for MetadataBlob {}
6161

@@ -96,7 +96,7 @@ crate struct CrateMetadata {
9696
/// Source maps for code from the crate.
9797
source_map_import_info: OnceCell<Vec<ImportedSourceFile>>,
9898
/// For every definition in this crate, maps its `DefPathHash` to its `DefIndex`.
99-
def_path_hash_map: DefPathHashMap<'static>,
99+
def_path_hash_map: DefPathHashMapRef<'static>,
100100
/// Likewise for ExpnHash.
101101
expn_hash_map: OnceCell<UnhashMap<ExpnHash, ExpnIndex>>,
102102
/// Used for decoding interpret::AllocIds in a cached & thread-safe manner.

compiler/rustc_metadata/src/rmeta/def_path_hash_map.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,44 @@ use crate::rmeta::DecodeContext;
22
use crate::rmeta::EncodeContext;
33
use crate::rmeta::MetadataBlob;
44
use rustc_data_structures::owning_ref::OwningRef;
5-
use rustc_hir::def_path_hash_map::{
6-
Config as HashMapConfig, DefPathHashMap as DefPathHashMapInner,
7-
};
5+
use rustc_hir::def_path_hash_map::{Config as HashMapConfig, DefPathHashMap};
86
use rustc_serialize::{opaque, Decodable, Decoder, Encodable, Encoder};
97
use rustc_span::def_id::{DefIndex, DefPathHash};
108

11-
crate enum DefPathHashMap<'tcx> {
9+
crate enum DefPathHashMapRef<'tcx> {
1210
OwnedFromMetadata(odht::HashTable<HashMapConfig, OwningRef<MetadataBlob, [u8]>>),
13-
BorrowedFromTcx(&'tcx DefPathHashMapInner),
11+
BorrowedFromTcx(&'tcx DefPathHashMap),
1412
}
1513

16-
impl DefPathHashMap<'tcx> {
14+
impl DefPathHashMapRef<'tcx> {
1715
#[inline]
1816
pub fn def_path_hash_to_def_index(&self, def_path_hash: &DefPathHash) -> DefIndex {
1917
match *self {
20-
DefPathHashMap::OwnedFromMetadata(ref map) => map.get(def_path_hash).unwrap(),
21-
DefPathHashMap::BorrowedFromTcx(_) => {
18+
DefPathHashMapRef::OwnedFromMetadata(ref map) => map.get(def_path_hash).unwrap(),
19+
DefPathHashMapRef::BorrowedFromTcx(_) => {
2220
panic!("DefPathHashMap::BorrowedFromTcx variant only exists for serialization")
2321
}
2422
}
2523
}
2624
}
2725

28-
impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for DefPathHashMap<'tcx> {
26+
impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for DefPathHashMapRef<'tcx> {
2927
fn encode(&self, e: &mut EncodeContext<'a, 'tcx>) -> opaque::EncodeResult {
3028
match *self {
31-
DefPathHashMap::BorrowedFromTcx(def_path_hash_map) => {
29+
DefPathHashMapRef::BorrowedFromTcx(def_path_hash_map) => {
3230
let bytes = def_path_hash_map.raw_bytes();
3331
e.emit_usize(bytes.len())?;
3432
e.emit_raw_bytes(bytes)
3533
}
36-
DefPathHashMap::OwnedFromMetadata(_) => {
34+
DefPathHashMapRef::OwnedFromMetadata(_) => {
3735
panic!("DefPathHashMap::OwnedFromMetadata variant only exists for deserialization")
3836
}
3937
}
4038
}
4139
}
4240

43-
impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for DefPathHashMap<'static> {
44-
fn decode(d: &mut DecodeContext<'a, 'tcx>) -> Result<DefPathHashMap<'static>, String> {
41+
impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for DefPathHashMapRef<'static> {
42+
fn decode(d: &mut DecodeContext<'a, 'tcx>) -> Result<DefPathHashMapRef<'static>, String> {
4543
// Import TyDecoder so we can access the DecodeContext::position() method
4644
use crate::rustc_middle::ty::codec::TyDecoder;
4745

@@ -55,6 +53,6 @@ impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for DefPathHashMap<'static> {
5553
let _ = d.read_raw_bytes(len);
5654

5755
let inner = odht::HashTable::from_raw_bytes(o).map_err(|e| format!("{}", e))?;
58-
Ok(DefPathHashMap::OwnedFromMetadata(inner))
56+
Ok(DefPathHashMapRef::OwnedFromMetadata(inner))
5957
}
6058
}

compiler/rustc_metadata/src/rmeta/encoder.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::rmeta::def_path_hash_map::DefPathHashMap;
1+
use crate::rmeta::def_path_hash_map::DefPathHashMapRef;
22
use crate::rmeta::table::{FixedSizeEncoding, TableBuilder};
33
use crate::rmeta::*;
44

@@ -473,8 +473,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
473473
}
474474
}
475475

476-
fn encode_def_path_hash_map(&mut self) -> Lazy<DefPathHashMap<'tcx>> {
477-
self.lazy(DefPathHashMap::BorrowedFromTcx(
476+
fn encode_def_path_hash_map(&mut self) -> Lazy<DefPathHashMapRef<'tcx>> {
477+
self.lazy(DefPathHashMapRef::BorrowedFromTcx(
478478
self.tcx.resolutions(()).definitions.def_path_hash_to_def_index_map(),
479479
))
480480
}

compiler/rustc_metadata/src/rmeta/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use decoder::Metadata;
2-
use def_path_hash_map::DefPathHashMap;
2+
use def_path_hash_map::DefPathHashMapRef;
33
use table::{Table, TableBuilder};
44

55
use rustc_ast::{self as ast, MacroDef};
@@ -233,7 +233,7 @@ crate struct CrateRoot<'tcx> {
233233
expn_data: ExpnDataTable,
234234
expn_hashes: ExpnHashTable,
235235

236-
def_path_hash_map: Lazy<DefPathHashMap<'tcx>>,
236+
def_path_hash_map: Lazy<DefPathHashMapRef<'tcx>>,
237237

238238
source_map: Lazy<[rustc_span::SourceFile]>,
239239

0 commit comments

Comments
 (0)