@@ -38,7 +38,7 @@ use super::Clean;
3838///
3939/// The returned value is `None` if the definition could not be inlined,
4040/// and `Some` of a vector of items if it was successfully expanded.
41- pub fn try_inline ( cx : & DocContext , def : Def , name : ast:: Name )
41+ pub fn try_inline ( cx : & DocContext , def : Def , name : ast:: Name , visited : & mut FxHashSet < DefId > )
4242 -> Option < Vec < clean:: Item > > {
4343 if def == Def :: Err { return None }
4444 let did = def. def_id ( ) ;
@@ -87,7 +87,7 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name)
8787 Def :: StructCtor ( ..) => return Some ( Vec :: new ( ) ) ,
8888 Def :: Mod ( did) => {
8989 record_extern_fqn ( cx, did, clean:: TypeKind :: Module ) ;
90- clean:: ModuleItem ( build_module ( cx, did) )
90+ clean:: ModuleItem ( build_module ( cx, did, visited ) )
9191 }
9292 Def :: Static ( did, mtbl) => {
9393 record_extern_fqn ( cx, did, clean:: TypeKind :: Static ) ;
@@ -385,24 +385,24 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
385385 } ) ;
386386}
387387
388- fn build_module ( cx : & DocContext , did : DefId ) -> clean:: Module {
388+ fn build_module ( cx : & DocContext , did : DefId , visited : & mut FxHashSet < DefId > ) -> clean:: Module {
389389 let mut items = Vec :: new ( ) ;
390- fill_in ( cx, did, & mut items) ;
390+ fill_in ( cx, did, & mut items, visited ) ;
391391 return clean:: Module {
392392 items,
393393 is_crate : false ,
394394 } ;
395395
396- fn fill_in ( cx : & DocContext , did : DefId , items : & mut Vec < clean:: Item > ) {
396+ fn fill_in ( cx : & DocContext , did : DefId , items : & mut Vec < clean:: Item > ,
397+ visited : & mut FxHashSet < DefId > ) {
397398 // If we're re-exporting a re-export it may actually re-export something in
398399 // two namespaces, so the target may be listed twice. Make sure we only
399400 // visit each node at most once.
400- let mut visited = FxHashSet ( ) ;
401401 for & item in cx. tcx . item_children ( did) . iter ( ) {
402402 let def_id = item. def . def_id ( ) ;
403403 if item. vis == ty:: Visibility :: Public {
404- if !visited. insert ( def_id) { continue }
405- if let Some ( i) = try_inline ( cx, item. def , item. ident . name ) {
404+ if did == def_id || !visited. insert ( def_id) { continue }
405+ if let Some ( i) = try_inline ( cx, item. def , item. ident . name , visited ) {
406406 items. extend ( i)
407407 }
408408 }
0 commit comments