@@ -14,7 +14,8 @@ use cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary};
14
14
use schema:: * ;
15
15
16
16
use rustc_data_structures:: sync:: { Lrc , ReadGuard } ;
17
- use rustc:: hir:: map:: { DefKey , DefPath , DefPathData , DefPathHash } ;
17
+ use rustc:: hir:: map:: { DefKey , DefPath , DefPathData , DefPathHash ,
18
+ DisambiguatedDefPathData } ;
18
19
use rustc:: hir;
19
20
use rustc:: middle:: cstore:: { LinkagePreference , ExternConstBody ,
20
21
ExternBodyNestedBodies } ;
@@ -1115,7 +1116,23 @@ impl<'a, 'tcx> CrateMetadata {
1115
1116
1116
1117
#[ inline]
1117
1118
pub fn def_key ( & self , index : DefIndex ) -> DefKey {
1118
- self . def_path_table . def_key ( index)
1119
+ if !self . is_proc_macro ( index) {
1120
+ self . def_path_table . def_key ( index)
1121
+ } else {
1122
+ // FIXME(#49271) - It would be better if the DefIds were consistent
1123
+ // with the DefPathTable, but for proc-macro crates
1124
+ // they aren't.
1125
+ let name = self . proc_macros
1126
+ . as_ref ( )
1127
+ . unwrap ( ) [ index. to_proc_macro_index ( ) ] . 0 ;
1128
+ DefKey {
1129
+ parent : Some ( CRATE_DEF_INDEX ) ,
1130
+ disambiguated_data : DisambiguatedDefPathData {
1131
+ data : DefPathData :: MacroDef ( name. as_str ( ) ) ,
1132
+ disambiguator : 0 ,
1133
+ }
1134
+ }
1135
+ }
1119
1136
}
1120
1137
1121
1138
// Returns the path leading to the thing with this `id`.
0 commit comments