@@ -2,46 +2,44 @@ use crate::rmeta::DecodeContext;
2
2
use crate :: rmeta:: EncodeContext ;
3
3
use crate :: rmeta:: MetadataBlob ;
4
4
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 } ;
8
6
use rustc_serialize:: { opaque, Decodable , Decoder , Encodable , Encoder } ;
9
7
use rustc_span:: def_id:: { DefIndex , DefPathHash } ;
10
8
11
- crate enum DefPathHashMap < ' tcx > {
9
+ crate enum DefPathHashMapRef < ' tcx > {
12
10
OwnedFromMetadata ( odht:: HashTable < HashMapConfig , OwningRef < MetadataBlob , [ u8 ] > > ) ,
13
- BorrowedFromTcx ( & ' tcx DefPathHashMapInner ) ,
11
+ BorrowedFromTcx ( & ' tcx DefPathHashMap ) ,
14
12
}
15
13
16
- impl DefPathHashMap < ' tcx > {
14
+ impl DefPathHashMapRef < ' tcx > {
17
15
#[ inline]
18
16
pub fn def_path_hash_to_def_index ( & self , def_path_hash : & DefPathHash ) -> DefIndex {
19
17
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 ( _) => {
22
20
panic ! ( "DefPathHashMap::BorrowedFromTcx variant only exists for serialization" )
23
21
}
24
22
}
25
23
}
26
24
}
27
25
28
- impl < ' a , ' tcx > Encodable < EncodeContext < ' a , ' tcx > > for DefPathHashMap < ' tcx > {
26
+ impl < ' a , ' tcx > Encodable < EncodeContext < ' a , ' tcx > > for DefPathHashMapRef < ' tcx > {
29
27
fn encode ( & self , e : & mut EncodeContext < ' a , ' tcx > ) -> opaque:: EncodeResult {
30
28
match * self {
31
- DefPathHashMap :: BorrowedFromTcx ( def_path_hash_map) => {
29
+ DefPathHashMapRef :: BorrowedFromTcx ( def_path_hash_map) => {
32
30
let bytes = def_path_hash_map. raw_bytes ( ) ;
33
31
e. emit_usize ( bytes. len ( ) ) ?;
34
32
e. emit_raw_bytes ( bytes)
35
33
}
36
- DefPathHashMap :: OwnedFromMetadata ( _) => {
34
+ DefPathHashMapRef :: OwnedFromMetadata ( _) => {
37
35
panic ! ( "DefPathHashMap::OwnedFromMetadata variant only exists for deserialization" )
38
36
}
39
37
}
40
38
}
41
39
}
42
40
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 > {
45
43
// Import TyDecoder so we can access the DecodeContext::position() method
46
44
use crate :: rustc_middle:: ty:: codec:: TyDecoder ;
47
45
@@ -55,6 +53,6 @@ impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for DefPathHashMap<'static> {
55
53
let _ = d. read_raw_bytes ( len) ;
56
54
57
55
let inner = odht:: HashTable :: from_raw_bytes ( o) . map_err ( |e| format ! ( "{}" , e) ) ?;
58
- Ok ( DefPathHashMap :: OwnedFromMetadata ( inner) )
56
+ Ok ( DefPathHashMapRef :: OwnedFromMetadata ( inner) )
59
57
}
60
58
}
0 commit comments