@@ -2,46 +2,44 @@ use crate::rmeta::DecodeContext;
22use crate :: rmeta:: EncodeContext ;
33use crate :: rmeta:: MetadataBlob ;
44use 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 } ;
86use rustc_serialize:: { opaque, Decodable , Decoder , Encodable , Encoder } ;
97use 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}
0 commit comments