@@ -210,12 +210,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
210210
211211 let visible_parent = visible_parent_map. get ( & cur_def) . cloned ( ) ;
212212 let actual_parent = self . parent ( cur_def) ;
213- debug ! (
214- "try_push_visible_item_path: visible_parent={:?} actual_parent={:?}" ,
215- visible_parent, actual_parent,
216- ) ;
217213
218214 let data = cur_def_key. disambiguated_data . data ;
215+ debug ! (
216+ "try_push_visible_item_path: data={:?} visible_parent={:?} actual_parent={:?}" ,
217+ data, visible_parent, actual_parent,
218+ ) ;
219219 let symbol = match data {
220220 // In order to output a path that could actually be imported (valid and visible),
221221 // we need to handle re-exports correctly.
@@ -248,16 +248,16 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
248248 // the children of the visible parent (as was done when computing
249249 // `visible_parent_map`), looking for the specific child we currently have and then
250250 // have access to the re-exported name.
251- DefPathData :: Module ( module_name ) if visible_parent != actual_parent => {
252- let mut name : Option < ast :: Ident > = None ;
253- if let Some ( visible_parent) = visible_parent {
254- for child in self . item_children ( visible_parent ) . iter ( ) {
255- if child . def . def_id ( ) == cur_def {
256- name = Some ( child . ident ) ;
257- }
258- }
259- }
260- name . map ( |n| n . as_str ( ) ) . unwrap_or ( module_name . as_str ( ) )
251+ DefPathData :: Module ( actual_name ) |
252+ DefPathData :: TypeNs ( actual_name ) if visible_parent != actual_parent => {
253+ visible_parent
254+ . and_then ( |parent| {
255+ self . item_children ( parent )
256+ . iter ( )
257+ . find ( |child| child . def . def_id ( ) == cur_def )
258+ . map ( |child| child . ident . as_str ( ) )
259+ } )
260+ . unwrap_or_else ( || actual_name . as_str ( ) )
261261 } ,
262262 _ => {
263263 data. get_opt_name ( ) . map ( |n| n. as_str ( ) ) . unwrap_or_else ( || {
0 commit comments