@@ -25,7 +25,7 @@ use rustc_middle::ty::{AssocItemContainer, SymbolName};
2525use rustc_middle:: util:: common:: to_readable_str;
2626use rustc_middle:: { bug, span_bug} ;
2727use rustc_serialize:: { Decodable , Decoder , Encodable , Encoder , opaque} ;
28- use rustc_session:: config:: { CrateType , OptLevel } ;
28+ use rustc_session:: config:: { CrateType , OptLevel , ResolveDocLinks } ;
2929use rustc_span:: hygiene:: HygieneEncodeContext ;
3030use rustc_span:: symbol:: sym;
3131use rustc_span:: {
@@ -134,7 +134,13 @@ impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for ExpnIndex {
134134
135135impl < ' a , ' tcx > SpanEncoder for EncodeContext < ' a , ' tcx > {
136136 fn encode_crate_num ( & mut self , crate_num : CrateNum ) {
137- if crate_num != LOCAL_CRATE && self . is_proc_macro {
137+ if crate_num != LOCAL_CRATE
138+ && ( self . is_proc_macro
139+ && !matches ! (
140+ self . tcx. sess. opts. resolve_doc_links,
141+ ResolveDocLinks :: ExportedMetadata
142+ ) )
143+ {
138144 panic ! ( "Attempted to encode non-local CrateNum {crate_num:?} for proc-macro crate" ) ;
139145 }
140146 self . emit_u32 ( crate_num. as_u32 ( ) ) ;
@@ -495,7 +501,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
495501
496502 fn encode_def_path_table ( & mut self ) {
497503 let table = self . tcx . def_path_table ( ) ;
498- if self . is_proc_macro {
504+ if self . is_proc_macro
505+ && !matches ! ( self . tcx. sess. opts. resolve_doc_links, ResolveDocLinks :: ExportedMetadata )
506+ {
499507 for def_index in std:: iter:: once ( CRATE_DEF_INDEX )
500508 . chain ( self . tcx . resolutions ( ( ) ) . proc_macros . iter ( ) . map ( |p| p. local_def_index ) )
501509 {
@@ -1373,7 +1381,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13731381
13741382 // Proc-macro crates only export proc-macro items, which are looked
13751383 // up using `proc_macro_data`
1376- if self . is_proc_macro {
1384+ if self . is_proc_macro
1385+ && !matches ! ( self . tcx. sess. opts. resolve_doc_links, ResolveDocLinks :: ExportedMetadata )
1386+ {
13771387 return ;
13781388 }
13791389
0 commit comments