@@ -25,7 +25,7 @@ use rustc_middle::ty::{AssocItemContainer, SymbolName};
25
25
use rustc_middle:: util:: common:: to_readable_str;
26
26
use rustc_middle:: { bug, span_bug} ;
27
27
use rustc_serialize:: { Decodable , Decoder , Encodable , Encoder , opaque} ;
28
- use rustc_session:: config:: { CrateType , OptLevel } ;
28
+ use rustc_session:: config:: { CrateType , OptLevel , ResolveDocLinks } ;
29
29
use rustc_span:: hygiene:: HygieneEncodeContext ;
30
30
use rustc_span:: symbol:: sym;
31
31
use rustc_span:: {
@@ -134,7 +134,13 @@ impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for ExpnIndex {
134
134
135
135
impl < ' a , ' tcx > SpanEncoder for EncodeContext < ' a , ' tcx > {
136
136
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
+ {
138
144
panic ! ( "Attempted to encode non-local CrateNum {crate_num:?} for proc-macro crate" ) ;
139
145
}
140
146
self . emit_u32 ( crate_num. as_u32 ( ) ) ;
@@ -495,7 +501,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
495
501
496
502
fn encode_def_path_table ( & mut self ) {
497
503
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
+ {
499
507
for def_index in std:: iter:: once ( CRATE_DEF_INDEX )
500
508
. chain ( self . tcx . resolutions ( ( ) ) . proc_macros . iter ( ) . map ( |p| p. local_def_index ) )
501
509
{
@@ -1373,7 +1381,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1373
1381
1374
1382
// Proc-macro crates only export proc-macro items, which are looked
1375
1383
// 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
+ {
1377
1387
return ;
1378
1388
}
1379
1389
0 commit comments