diff options
| author | John Clements <clements@racket-lang.org> | 2014-07-09 14:48:12 -0700 |
|---|---|---|
| committer | John Clements <clements@racket-lang.org> | 2014-07-11 10:32:41 -0700 |
| commit | 53642eed801d157613de0998cdcf0a3da8c36cb3 (patch) | |
| tree | 4d9232bac52072c177895e7de997b5ca00da98d5 /src/libsyntax/ext | |
| parent | f1ad425199b0d89dab275a8c8f6f29a73d316f70 (diff) | |
| download | rust-53642eed801d157613de0998cdcf0a3da8c36cb3.tar.gz rust-53642eed801d157613de0998cdcf0a3da8c36cb3.zip | |
make walk/visit_mac opt-in only
macros can expand into arbitrary items, exprs, etc. This means that using a default walker or folder on an AST before macro expansion is complete will miss things (the things that the macros expand into). As a partial fence against this, this commit moves the default traversal of macros into a separate procedure, and makes the default trait implementation signal an error. This means that Folders and Visitors can traverse macros if they want to, but they need to explicitly add an impl that calls the walk_mac or fold_mac procedure This should prevent problems down the road.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index e8a78e85d89..084faca02c5 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -753,7 +753,6 @@ impl Visitor<()> for PatIdentFinder { _ => visit::walk_pat(self, pattern, ()) } } - } /// find the PatIdent paths in a pattern @@ -902,6 +901,9 @@ impl<'a> Folder for IdentRenamer<'a> { ctxt: mtwt::apply_renames(self.renames, id.ctxt), } } + fn fold_mac(&mut self, macro: &ast::Mac) -> ast::Mac { + fold::fold_mac(macro, self) + } } /// A tree-folder that applies every rename in its list to @@ -931,6 +933,9 @@ impl<'a> Folder for PatIdentRenamer<'a> { _ => noop_fold_pat(pat, self) } } + fn fold_mac(&mut self, macro: &ast::Mac) -> ast::Mac { + fold::fold_mac(macro, self) + } } // expand a method |
