@@ -73,6 +73,8 @@ pub(crate) struct Context<'tcx> {
7373 pub ( crate ) include_sources : bool ,
7474 /// Collection of all types with notable traits referenced in the current module.
7575 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 ,
7678}
7779
7880// `Context` is cloned a lot, so we don't want the size to grow unexpectedly.
@@ -171,6 +173,19 @@ impl<'tcx> Context<'tcx> {
171173 }
172174
173175 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+ }
174189 let mut title = String :: new ( ) ;
175190 if !is_module {
176191 title. push_str ( it. name . unwrap ( ) . as_str ( ) ) ;
@@ -205,7 +220,7 @@ impl<'tcx> Context<'tcx> {
205220 tyname. as_str ( )
206221 } ;
207222
208- if !self . render_redirect_pages {
223+ if !render_redirect_pages {
209224 let clone_shared = Rc :: clone ( & self . shared ) ;
210225 let page = layout:: Page {
211226 css_class : tyname_s,
@@ -545,6 +560,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
545560 shared : Rc :: new ( scx) ,
546561 include_sources,
547562 types_with_notable_traits : FxHashSet :: default ( ) ,
563+ is_inside_inlined_module : false ,
548564 } ;
549565
550566 if emit_crate {
@@ -574,6 +590,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
574590 shared : Rc :: clone ( & self . shared ) ,
575591 include_sources : self . include_sources ,
576592 types_with_notable_traits : FxHashSet :: default ( ) ,
593+ is_inside_inlined_module : self . is_inside_inlined_module ,
577594 }
578595 }
579596
@@ -768,12 +785,22 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
768785
769786 info ! ( "Recursing into {}" , self . dst. display( ) ) ;
770787
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 ;
777804 }
778805
779806 // Render sidebar-items.js used throughout this module.
0 commit comments