@@ -130,9 +130,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
130
130
global : path. global ,
131
131
segments : segs} ;
132
132
let qualname = if i == 0 && path. global {
133
- let mut result = "::" . to_string ( ) ;
134
- result. push_str ( & path_to_string ( & sub_path) [ ] ) ;
135
- result
133
+ format ( "::{}" , path_to_string ( & sub_path) )
136
134
} else {
137
135
path_to_string ( & sub_path)
138
136
} ;
@@ -143,6 +141,10 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
143
141
result
144
142
}
145
143
144
+ // The global arg allows us to override the global-ness of the path (which
145
+ // actually means 'does the path start with `::`', rather than 'is the path
146
+ // semantically global). We use the override for `use` imports (etc.) where
147
+ // the syntax is non-global, but the semantics are global.
146
148
fn write_sub_paths ( & mut self , path : & ast:: Path , global : bool ) {
147
149
let sub_paths = self . process_path_prefixes ( path) ;
148
150
for ( i, & ( ref span, ref qualname) ) in sub_paths. iter ( ) . enumerate ( ) {
@@ -159,7 +161,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
159
161
}
160
162
161
163
// As write_sub_paths, but does not process the last ident in the path (assuming it
162
- // will be processed elsewhere).
164
+ // will be processed elsewhere). See note on write_sub_paths about global.
163
165
fn write_sub_paths_truncated ( & mut self , path : & ast:: Path , global : bool ) {
164
166
let sub_paths = self . process_path_prefixes ( path) ;
165
167
let len = sub_paths. len ( ) ;
@@ -291,7 +293,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
291
293
292
294
let mut scope_id;
293
295
// The qualname for a method is the trait name or name of the struct in an impl in
294
- // which the method is declared in followed by the method's name.
296
+ // which the method is declared in, followed by the method's name.
295
297
let qualname = match ty:: impl_of_method ( & self . analysis . ty_cx ,
296
298
ast_util:: local_def ( method. id ) ) {
297
299
Some ( impl_id) => match self . analysis . ty_cx . map . get ( impl_id. node ) {
@@ -311,7 +313,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
311
313
} ,
312
314
None => { }
313
315
}
314
- result. push_str ( ">:: " ) ;
316
+ result. push_str ( ">" ) ;
315
317
result
316
318
}
317
319
_ => {
@@ -336,8 +338,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
336
338
scope_id = def_id. node ;
337
339
match self . analysis . ty_cx . map . get ( def_id. node ) {
338
340
NodeItem ( _) => {
339
- let mut result = ty:: item_path_str ( & self . analysis . ty_cx , def_id) ;
340
- result. push_str ( "::" ) ;
341
+ format ! ( "::{}" , ty:: item_path_str( & self . analysis. ty_cx, def_id) )
341
342
result
342
343
}
343
344
_ => {
@@ -355,7 +356,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
355
356
} ,
356
357
} ;
357
358
358
- let qualname = format ! ( "::{} {}" , qualname, get_ident( method. pe_ident( ) ) . get( ) ) ;
359
+ let qualname = format ! ( "{}:: {}" , qualname, get_ident( method. pe_ident( ) ) . get( ) ) ;
359
360
let qualname = & qualname[ ] ;
360
361
361
362
// record the decl for this def (if it has one)
0 commit comments