@@ -365,6 +365,11 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
365365 } ) ;
366366 true
367367 }
368+ hir_map:: NodeStructCtor ( _) if !glob => {
369+ // struct constructors always show up alongside their struct definitions, we've
370+ // already processed that so just discard this
371+ true
372+ }
368373 _ => false ,
369374 } ;
370375 self . view_item_stack . remove ( & def_node_id) ;
@@ -425,17 +430,29 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
425430 }
426431 } ) ;
427432 let name = if is_glob { None } else { Some ( name) } ;
428- for ns in path. defs . valid_defs ( ) . filter ( |& d| {
429- self . maybe_inline_local ( item. id , d, name, is_glob, om, please_inline)
430- } ) . filter_map ( |d| d. namespace ( ) ) {
431- path. defs [ ns] = Def :: Err ;
433+ let mut only_err = path. defs . all_err ( ) ;
434+ for def in path. defs . valid_defs ( ) {
435+ if self . maybe_inline_local ( item. id , def, name, is_glob, om, please_inline) {
436+ debug ! ( "definition for {:?} ns in {:?} was inlined, \
437+ discarding def from import",
438+ def. namespace( ) , path) ;
439+ if let Some ( ns) = def. namespace ( ) {
440+ // clear out the Def for this namespace so we don't also document
441+ // the import statement for it
442+ path. defs [ ns] = Def :: Err ;
443+ }
444+ }
432445 }
433446
434- if path. defs . all_err ( ) {
447+ if path. defs . all_err ( ) && !only_err {
448+ debug ! ( "all defs from {:?} were inlined, exiting" , path) ;
449+ // everything that was documented here was inlined, so scrap the import
450+ // statement
435451 return ;
436452 }
437453 }
438454
455+ debug ! ( "remaining namespaces for {:?}: {:?}" , path, path. defs) ;
439456 om. imports . push ( Import {
440457 name,
441458 id : item. id ,
0 commit comments