Skip to content

Commit 9ba9966

Browse files
committed
Review changes
1 parent b159d9c commit 9ba9966

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/librustc_trans/save/mod.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
130130
global: path.global,
131131
segments: segs};
132132
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))
136134
} else {
137135
path_to_string(&sub_path)
138136
};
@@ -143,6 +141,10 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
143141
result
144142
}
145143

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.
146148
fn write_sub_paths(&mut self, path: &ast::Path, global: bool) {
147149
let sub_paths = self.process_path_prefixes(path);
148150
for (i, &(ref span, ref qualname)) in sub_paths.iter().enumerate() {
@@ -159,7 +161,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
159161
}
160162

161163
// 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.
163165
fn write_sub_paths_truncated(&mut self, path: &ast::Path, global: bool) {
164166
let sub_paths = self.process_path_prefixes(path);
165167
let len = sub_paths.len();
@@ -291,7 +293,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
291293

292294
let mut scope_id;
293295
// 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.
295297
let qualname = match ty::impl_of_method(&self.analysis.ty_cx,
296298
ast_util::local_def(method.id)) {
297299
Some(impl_id) => match self.analysis.ty_cx.map.get(impl_id.node) {
@@ -311,7 +313,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
311313
},
312314
None => {}
313315
}
314-
result.push_str(">::");
316+
result.push_str(">");
315317
result
316318
}
317319
_ => {
@@ -336,8 +338,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
336338
scope_id = def_id.node;
337339
match self.analysis.ty_cx.map.get(def_id.node) {
338340
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))
341342
result
342343
}
343344
_ => {
@@ -355,7 +356,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
355356
},
356357
};
357358

358-
let qualname = format!("::{}{}", qualname, get_ident(method.pe_ident()).get());
359+
let qualname = format!("{}::{}", qualname, get_ident(method.pe_ident()).get());
359360
let qualname = &qualname[];
360361

361362
// record the decl for this def (if it has one)

0 commit comments

Comments
 (0)