@@ -38,7 +38,7 @@ use super::Clean;
38
38
///
39
39
/// The returned value is `None` if the definition could not be inlined,
40
40
/// 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 > )
42
42
-> Option < Vec < clean:: Item > > {
43
43
if def == Def :: Err { return None }
44
44
let did = def. def_id ( ) ;
@@ -87,7 +87,7 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name)
87
87
Def :: StructCtor ( ..) => return Some ( Vec :: new ( ) ) ,
88
88
Def :: Mod ( did) => {
89
89
record_extern_fqn ( cx, did, clean:: TypeKind :: Module ) ;
90
- clean:: ModuleItem ( build_module ( cx, did) )
90
+ clean:: ModuleItem ( build_module ( cx, did, visited ) )
91
91
}
92
92
Def :: Static ( did, mtbl) => {
93
93
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>) {
385
385
} ) ;
386
386
}
387
387
388
- fn build_module ( cx : & DocContext , did : DefId ) -> clean:: Module {
388
+ fn build_module ( cx : & DocContext , did : DefId , visited : & mut FxHashSet < DefId > ) -> clean:: Module {
389
389
let mut items = Vec :: new ( ) ;
390
- fill_in ( cx, did, & mut items) ;
390
+ fill_in ( cx, did, & mut items, visited ) ;
391
391
return clean:: Module {
392
392
items,
393
393
is_crate : false ,
394
394
} ;
395
395
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 > ) {
397
398
// If we're re-exporting a re-export it may actually re-export something in
398
399
// two namespaces, so the target may be listed twice. Make sure we only
399
400
// visit each node at most once.
400
- let mut visited = FxHashSet ( ) ;
401
401
for & item in cx. tcx . item_children ( did) . iter ( ) {
402
402
let def_id = item. def . def_id ( ) ;
403
403
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 ) {
406
406
items. extend ( i)
407
407
}
408
408
}
0 commit comments