]> git.lizzy.rs Git - rust.git/commit
auto merge of #15601 : jbclements/rust/disable-default-macro-behavior, r=alexcrichton
authorbors <bors@rust-lang.org>
Sat, 12 Jul 2014 11:06:39 +0000 (11:06 +0000)
committerbors <bors@rust-lang.org>
Sat, 12 Jul 2014 11:06:39 +0000 (11:06 +0000)
commitcdd6346f458084ef9f9e6e1b640225be4a8aca70
tree92473d4a48cf9609db4295a4ea546916c38dfe99
parent767f4a7937c9f8a56cf4d1ac8fd111d481312f34
parentc253b3675ab03b6c64021e8acee3988cea81f3f9
auto merge of #15601 : jbclements/rust/disable-default-macro-behavior, r=alexcrichton

Our AST definition can include macro invocations, which can expand into all kinds of things. Macro invocations are expanded away during expansion time, and the rest of the compiler doesn't have to deal with them. However, we have no way of enforcing this.

This patch adds two protective mechanisms.

First, it adds a (quick) explicit check that ensures there are no macro invocations remaining in the AST after expansion. Second, it updates the visit and fold mechanisms so that by default, they will not traverse macro invocations. It's easy enough to add this, if desired (it's documented in the source, and examples appear, e.g. in the IdentFinder.

Along the way, I also consulted with @sfackler to refactor the macro export mechanism so that it stores macro text spans in a side table, rather than leaving them in the AST.
src/librustc/driver/driver.rs
src/librustc/driver/session.rs
src/librustc/metadata/encoder.rs
src/libsyntax/ast.rs
src/libsyntax/ext/expand.rs