@@ -73,6 +73,8 @@ pub(crate) struct Context<'tcx> {
73
73
pub ( crate ) include_sources : bool ,
74
74
/// Collection of all types with notable traits referenced in the current module.
75
75
pub ( crate ) types_with_notable_traits : FxHashSet < clean:: Type > ,
76
+ /// Field used during rendering, to know if we're inside an inlined item.
77
+ pub ( crate ) is_inside_inlined_module : bool ,
76
78
}
77
79
78
80
// `Context` is cloned a lot, so we don't want the size to grow unexpectedly.
@@ -171,6 +173,19 @@ impl<'tcx> Context<'tcx> {
171
173
}
172
174
173
175
fn render_item ( & mut self , it : & clean:: Item , is_module : bool ) -> String {
176
+ let mut render_redirect_pages = self . render_redirect_pages ;
177
+ // If the item is stripped but inlined, links won't point to the item so no need to generate
178
+ // a file for it.
179
+ if it. is_stripped ( ) &&
180
+ let Some ( def_id) = it. def_id ( ) &&
181
+ def_id. is_local ( )
182
+ {
183
+ if self . is_inside_inlined_module || self . shared . cache . inlined_items . contains ( & def_id) {
184
+ // For now we're forced to generate a redirect page for stripped items until
185
+ // `record_extern_fqn` correctly points to external items.
186
+ render_redirect_pages = true ;
187
+ }
188
+ }
174
189
let mut title = String :: new ( ) ;
175
190
if !is_module {
176
191
title. push_str ( it. name . unwrap ( ) . as_str ( ) ) ;
@@ -205,7 +220,7 @@ impl<'tcx> Context<'tcx> {
205
220
tyname. as_str ( )
206
221
} ;
207
222
208
- if !self . render_redirect_pages {
223
+ if !render_redirect_pages {
209
224
let clone_shared = Rc :: clone ( & self . shared ) ;
210
225
let page = layout:: Page {
211
226
css_class : tyname_s,
@@ -545,6 +560,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
545
560
shared : Rc :: new ( scx) ,
546
561
include_sources,
547
562
types_with_notable_traits : FxHashSet :: default ( ) ,
563
+ is_inside_inlined_module : false ,
548
564
} ;
549
565
550
566
if emit_crate {
@@ -574,6 +590,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
574
590
shared : Rc :: clone ( & self . shared ) ,
575
591
include_sources : self . include_sources ,
576
592
types_with_notable_traits : FxHashSet :: default ( ) ,
593
+ is_inside_inlined_module : self . is_inside_inlined_module ,
577
594
}
578
595
}
579
596
@@ -768,12 +785,22 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
768
785
769
786
info ! ( "Recursing into {}" , self . dst. display( ) ) ;
770
787
771
- let buf = self . render_item ( item, true ) ;
772
- // buf will be empty if the module is stripped and there is no redirect for it
773
- if !buf. is_empty ( ) {
774
- self . shared . ensure_dir ( & self . dst ) ?;
775
- let joint_dst = self . dst . join ( "index.html" ) ;
776
- self . shared . fs . write ( joint_dst, buf) ?;
788
+ if !item. is_stripped ( ) {
789
+ let buf = self . render_item ( item, true ) ;
790
+ // buf will be empty if the module is stripped and there is no redirect for it
791
+ if !buf. is_empty ( ) {
792
+ self . shared . ensure_dir ( & self . dst ) ?;
793
+ let joint_dst = self . dst . join ( "index.html" ) ;
794
+ self . shared . fs . write ( joint_dst, buf) ?;
795
+ }
796
+ }
797
+ if !self . is_inside_inlined_module {
798
+ if let Some ( def_id) = item. def_id ( ) && self . cache ( ) . inlined_items . contains ( & def_id) {
799
+ self . is_inside_inlined_module = true ;
800
+ }
801
+ } else if item. is_doc_hidden ( ) {
802
+ // We're not inside an inlined module anymore since this one cannot be re-exported.
803
+ self . is_inside_inlined_module = false ;
777
804
}
778
805
779
806
// Render sidebar-items.js used throughout this module.
0 commit comments