@@ -210,12 +210,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
210
210
211
211
let visible_parent = visible_parent_map. get ( & cur_def) . cloned ( ) ;
212
212
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
- ) ;
217
213
218
214
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
+ ) ;
219
219
let symbol = match data {
220
220
// In order to output a path that could actually be imported (valid and visible),
221
221
// we need to handle re-exports correctly.
@@ -248,16 +248,16 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
248
248
// the children of the visible parent (as was done when computing
249
249
// `visible_parent_map`), looking for the specific child we currently have and then
250
250
// 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 ( ) )
261
261
} ,
262
262
_ => {
263
263
data. get_opt_name ( ) . map ( |n| n. as_str ( ) ) . unwrap_or_else ( || {
0 commit comments