|
13 | 13 | use cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary};
|
14 | 14 | use schema::*;
|
15 | 15 |
|
16 |
| -use rustc::hir::map::{DefKey, DefPath, DefPathData, DefPathHash}; |
| 16 | +use rustc::hir::map::{DefKey, DefPath, DefPathData, DefPathHash, |
| 17 | + DisambiguatedDefPathData}; |
17 | 18 | use rustc::hir;
|
18 | 19 | use rustc::middle::cstore::{LinkagePreference, ExternConstBody,
|
19 | 20 | ExternBodyNestedBodies};
|
@@ -1061,7 +1062,23 @@ impl<'a, 'tcx> CrateMetadata {
|
1061 | 1062 |
|
1062 | 1063 | #[inline]
|
1063 | 1064 | pub fn def_key(&self, index: DefIndex) -> DefKey {
|
1064 |
| - self.def_path_table.def_key(index) |
| 1065 | + if !self.is_proc_macro(index) { |
| 1066 | + self.def_path_table.def_key(index) |
| 1067 | + } else { |
| 1068 | + // FIXME(#49271) - It would be better if the DefIds were consistent |
| 1069 | + // with the DefPathTable, but for proc-macro crates |
| 1070 | + // they aren't. |
| 1071 | + let name = self.proc_macros |
| 1072 | + .as_ref() |
| 1073 | + .unwrap()[index.to_proc_macro_index()].0; |
| 1074 | + DefKey { |
| 1075 | + parent: Some(CRATE_DEF_INDEX), |
| 1076 | + disambiguated_data: DisambiguatedDefPathData { |
| 1077 | + data: DefPathData::MacroDef(name.as_str()), |
| 1078 | + disambiguator: 0, |
| 1079 | + } |
| 1080 | + } |
| 1081 | + } |
1065 | 1082 | }
|
1066 | 1083 |
|
1067 | 1084 | // Returns the path leading to the thing with this `id`.
|
|
0 commit comments