Skip to content

Commit

Permalink
Extend the libsyntax visitor to work over macro defs
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed May 13, 2017
1 parent df188b8 commit db82c57
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libsyntax/visit.rs
Expand Up @@ -27,6 +27,7 @@ use abi::Abi;
use ast::*;
use syntax_pos::Span;
use codemap::Spanned;
use tokenstream::ThinTokenStream;

#[derive(Copy, Clone, PartialEq, Eq)]
pub enum FnKind<'a> {
Expand Down Expand Up @@ -110,6 +111,9 @@ pub trait Visitor<'ast>: Sized {
// definition in your trait impl:
// visit::walk_mac(self, _mac)
}
fn visit_mac_def(&mut self, _mac: &'ast ThinTokenStream, _id: NodeId) {
// Nothing to do
}
fn visit_path(&mut self, path: &'ast Path, _id: NodeId) {
walk_path(self, path)
}
Expand Down Expand Up @@ -288,7 +292,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
walk_list!(visitor, visit_trait_item, methods);
}
ItemKind::Mac(ref mac) => visitor.visit_mac(mac),
ItemKind::MacroDef(..) => {},
ItemKind::MacroDef(ref ts) => visitor.visit_mac_def(ts, item.id),
}
walk_list!(visitor, visit_attribute, &item.attrs);
}
Expand Down

0 comments on commit db82c57

Please sign in to comment.