@@ -1545,7 +1545,7 @@ fn first_non_private<'tcx>(
1545
1545
if let Some ( ( segments, span) ) = saved_path {
1546
1546
return Some ( first_non_private_clean_path ( cx, path, segments, span) ) ;
1547
1547
}
1548
- let ( parent_def_id, mut ident) = match & path. segments [ ..] {
1548
+ let ( parent_def_id, ident) = match & path. segments [ ..] {
1549
1549
[ ] => return None ,
1550
1550
// Relative paths are available in the same scope as the owner.
1551
1551
[ leaf] => ( cx. tcx . local_parent ( hir_id. owner . def_id ) , leaf. ident ) ,
@@ -1569,6 +1569,7 @@ fn first_non_private<'tcx>(
1569
1569
// Absolute paths are not. We start from the parent of the item.
1570
1570
[ .., parent, leaf] => ( parent. res . opt_def_id ( ) ?. as_local ( ) ?, leaf. ident ) ,
1571
1571
} ;
1572
+ let hir = cx. tcx . hir ( ) ;
1572
1573
// First we try to get the `DefId` of the item.
1573
1574
for child in
1574
1575
cx. tcx . module_children_local ( parent_def_id) . iter ( ) . filter ( move |c| c. ident == ident)
@@ -1581,29 +1582,24 @@ fn first_non_private<'tcx>(
1581
1582
let mut last_path_res = None ;
1582
1583
' reexps: for reexp in child. reexport_chain . iter ( ) {
1583
1584
if let Some ( use_def_id) = reexp. id ( ) &&
1584
- let Some ( local_use_def_id) = use_def_id. as_local ( )
1585
+ let Some ( local_use_def_id) = use_def_id. as_local ( ) &&
1586
+ let Some ( hir:: Node :: Item ( item) ) = hir. find_by_def_id ( local_use_def_id) &&
1587
+ let hir:: ItemKind :: Use ( path, _) = item. kind
1585
1588
{
1586
- let hir = cx. tcx . hir ( ) ;
1587
- for item_id in hir. module_items ( cx. tcx . local_parent ( local_use_def_id) ) {
1588
- let item = hir. item ( item_id) ;
1589
- if item. ident == ident && let hir:: ItemKind :: Use ( path, _) = item. kind {
1590
- for res in & path. res {
1591
- if let Res :: Def ( DefKind :: Ctor ( ..) , _) | Res :: SelfCtor ( ..) = res {
1592
- continue ;
1593
- }
1594
- if ( cx. render_options . document_hidden ||
1595
- !cx. tcx . is_doc_hidden ( use_def_id) ) &&
1596
- // We never check for "cx.render_options.document_private"
1597
- // because if a re-export is not fully public, it's never
1598
- // documented.
1599
- cx. tcx . local_visibility ( local_use_def_id) . is_public ( ) {
1600
- break ' reexps;
1601
- }
1602
- ident = path. segments . last ( ) . unwrap ( ) . ident ;
1603
- last_path_res = Some ( ( path, res) ) ;
1604
- continue ' reexps;
1605
- }
1589
+ for res in & path. res {
1590
+ if let Res :: Def ( DefKind :: Ctor ( ..) , _) | Res :: SelfCtor ( ..) = res {
1591
+ continue ;
1592
+ }
1593
+ if ( cx. render_options . document_hidden ||
1594
+ !cx. tcx . is_doc_hidden ( use_def_id) ) &&
1595
+ // We never check for "cx.render_options.document_private"
1596
+ // because if a re-export is not fully public, it's never
1597
+ // documented.
1598
+ cx. tcx . local_visibility ( local_use_def_id) . is_public ( ) {
1599
+ break ' reexps;
1606
1600
}
1601
+ last_path_res = Some ( ( path, res) ) ;
1602
+ continue ' reexps;
1607
1603
}
1608
1604
}
1609
1605
}
0 commit comments