diff options
| author | bors <bors@rust-lang.org> | 2015-09-22 01:12:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-09-22 01:12:26 +0000 |
| commit | e9d2587766a30d30491ec96dab5cc5d741ae043a (patch) | |
| tree | 3c4f5ef22230bb3f67652a0e287a77b7aa39a0d8 /src/libsyntax | |
| parent | f93ab64d4a1a7ee91759a1594ab2a426b6cc657e (diff) | |
| parent | b44cb01bd73b32ffe046b4dcfa549a954d139ab2 (diff) | |
| download | rust-e9d2587766a30d30491ec96dab5cc5d741ae043a.tar.gz rust-e9d2587766a30d30491ec96dab5cc5d741ae043a.zip | |
Auto merge of #28364 - petrochenkov:usegate, r=alexcrichton
Closes https://github.com/rust-lang/rust/issues/28075 Closes https://github.com/rust-lang/rust/issues/28388 r? @eddyb cc @brson
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/visit.rs | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 8365a7375c6..f4f4c9dfc24 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -127,6 +127,9 @@ pub trait Visitor<'v> : Sized { fn visit_path(&mut self, path: &'v Path, _id: ast::NodeId) { walk_path(self, path) } + fn visit_path_list_item(&mut self, prefix: &'v Path, item: &'v PathListItem) { + walk_path_list_item(self, prefix, item) + } fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment) { walk_path_segment(self, path_span, path_segment) } @@ -209,33 +212,20 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { ItemExternCrate(..) => {} ItemUse(ref vp) => { match vp.node { - ViewPathSimple(ident, ref path) => { - visitor.visit_ident(vp.span, ident); + ViewPathSimple(_ident, ref path) => { visitor.visit_path(path, item.id); } ViewPathGlob(ref path) => { visitor.visit_path(path, item.id); } ViewPathList(ref prefix, ref list) => { - for id in list { - match id.node { - PathListIdent { name, rename, .. } => { - visitor.visit_ident(id.span, name); - if let Some(ident) = rename { - visitor.visit_ident(id.span, ident); - } - } - PathListMod { rename, .. } => { - if let Some(ident) = rename { - visitor.visit_ident(id.span, ident); - } - } + if !list.is_empty() { + for item in list { + visitor.visit_path_list_item(prefix, item) } + } else { + visitor.visit_path(prefix, item.id); } - - // Note that the `prefix` here is not a complete - // path, so we don't use `visit_path`. - walk_path(visitor, prefix); } } } @@ -417,6 +407,17 @@ pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path) { } } +pub fn walk_path_list_item<'v, V: Visitor<'v>>(visitor: &mut V, prefix: &'v Path, + item: &'v PathListItem) { + for segment in &prefix.segments { + visitor.visit_path_segment(prefix.span, segment); + } + + if let PathListIdent { name, .. } = item.node { + visitor.visit_ident(item.span, name); + } +} + pub fn walk_path_segment<'v, V: Visitor<'v>>(visitor: &mut V, path_span: Span, segment: &'v PathSegment) { |
