Skip to content

Commit 81aeb0c

Browse files
committed
Rollup merge of #33854 - petrochenkov:prefvis, r=eddyb
Apply visit_path to import prefixes by default Overriding `visit_path` is not enough to visit all paths, some import prefixes are not visited and `visit_path_list_item` need to be overridden as well. This PR removes this catch, it should be less error prone this way. Also, the prefix is visited once now, not repeatedly for each path list item. r? @eddyb
2 parents edd7d42 + 40285ca commit 81aeb0c

File tree

3 files changed

+8
-26
lines changed

3 files changed

+8
-26
lines changed

src/librustc/hir/intravisit.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,9 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
280280
visitor.visit_path(path, item.id);
281281
}
282282
ViewPathList(ref prefix, ref list) => {
283-
if !list.is_empty() {
284-
for item in list {
285-
visitor.visit_path_list_item(prefix, item)
286-
}
287-
} else {
288-
visitor.visit_path(prefix, item.id);
283+
visitor.visit_path(prefix, item.id);
284+
for item in list {
285+
visitor.visit_path_list_item(prefix, item)
289286
}
290287
}
291288
}
@@ -419,12 +416,8 @@ pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path) {
419416
}
420417

421418
pub fn walk_path_list_item<'v, V: Visitor<'v>>(visitor: &mut V,
422-
prefix: &'v Path,
419+
_prefix: &'v Path,
423420
item: &'v PathListItem) {
424-
for segment in &prefix.segments {
425-
visitor.visit_path_segment(prefix.span, segment);
426-
}
427-
428421
walk_opt_name(visitor, item.span, item.node.name());
429422
walk_opt_name(visitor, item.span, item.node.rename());
430423
}

src/librustc_incremental/calculate_svh.rs

-4
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,6 @@ mod svh_visitor {
401401
SawPath.hash(self.st); visit::walk_path(self, path)
402402
}
403403

404-
fn visit_path_list_item(&mut self, prefix: &'a Path, item: &'a PathListItem) {
405-
SawPath.hash(self.st); visit::walk_path_list_item(self, prefix, item)
406-
}
407-
408404
fn visit_block(&mut self, b: &'a Block) {
409405
SawBlock.hash(self.st); visit::walk_block(self, b)
410406
}

src/libsyntax/visit.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,9 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
233233
visitor.visit_path(path, item.id);
234234
}
235235
ViewPathList(ref prefix, ref list) => {
236-
if !list.is_empty() {
237-
for item in list {
238-
visitor.visit_path_list_item(prefix, item)
239-
}
240-
} else {
241-
visitor.visit_path(prefix, item.id);
236+
visitor.visit_path(prefix, item.id);
237+
for item in list {
238+
visitor.visit_path_list_item(prefix, item)
242239
}
243240
}
244241
}
@@ -368,12 +365,8 @@ pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path) {
368365
}
369366
}
370367

371-
pub fn walk_path_list_item<'v, V: Visitor<'v>>(visitor: &mut V, prefix: &'v Path,
368+
pub fn walk_path_list_item<'v, V: Visitor<'v>>(visitor: &mut V, _prefix: &'v Path,
372369
item: &'v PathListItem) {
373-
for segment in &prefix.segments {
374-
visitor.visit_path_segment(prefix.span, segment);
375-
}
376-
377370
walk_opt_ident(visitor, item.span, item.node.name());
378371
walk_opt_ident(visitor, item.span, item.node.rename());
379372
}

0 commit comments

Comments
 (0)