@@ -14,7 +14,8 @@ use cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary};
1414use schema:: * ;
1515
1616use 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 } ;
1819use rustc:: hir;
1920use rustc:: middle:: cstore:: { LinkagePreference , ExternConstBody ,
2021 ExternBodyNestedBodies } ;
@@ -1115,7 +1116,23 @@ impl<'a, 'tcx> CrateMetadata {
11151116
11161117 #[ inline]
11171118 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+ }
11191136 }
11201137
11211138 // Returns the path leading to the thing with this `id`.
0 commit comments