Skip to content

Commit db82c57

Browse files
committedMay 13, 2017
Extend the libsyntax visitor to work over macro defs
1 parent df188b8 commit db82c57

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎src/libsyntax/visit.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use abi::Abi;
2727
use ast::*;
2828
use syntax_pos::Span;
2929
use codemap::Spanned;
30+
use tokenstream::ThinTokenStream;
3031

3132
#[derive(Copy, Clone, PartialEq, Eq)]
3233
pub enum FnKind<'a> {
@@ -110,6 +111,9 @@ pub trait Visitor<'ast>: Sized {
110111
// definition in your trait impl:
111112
// visit::walk_mac(self, _mac)
112113
}
114+
fn visit_mac_def(&mut self, _mac: &'ast ThinTokenStream, _id: NodeId) {
115+
// Nothing to do
116+
}
113117
fn visit_path(&mut self, path: &'ast Path, _id: NodeId) {
114118
walk_path(self, path)
115119
}
@@ -288,7 +292,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
288292
walk_list!(visitor, visit_trait_item, methods);
289293
}
290294
ItemKind::Mac(ref mac) => visitor.visit_mac(mac),
291-
ItemKind::MacroDef(..) => {},
295+
ItemKind::MacroDef(ref ts) => visitor.visit_mac_def(ts, item.id),
292296
}
293297
walk_list!(visitor, visit_attribute, &item.attrs);
294298
}

0 commit comments

Comments
 (0)
Please sign in to comment.