about summary refs log tree commit diff
path: root/src/libsyntax/ext/expand.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-10-05 21:15:46 -0700
committerAlex Crichton <alex@alexcrichton.com>2013-10-31 13:46:10 -0700
commita49e65c2edad450cabc0745e94e7c031c5d4f7f8 (patch)
treed63f71dcbb24a4f7f74e60d4e06dd1779e823a0c /src/libsyntax/ext/expand.rs
parente976de32dc590f759e6c0c72d286844ca373e775 (diff)
downloadrust-a49e65c2edad450cabc0745e94e7c031c5d4f7f8.tar.gz
rust-a49e65c2edad450cabc0745e94e7c031c5d4f7f8.zip
Implement a concat!() format extension
This extension can be used to concatenate string literals at compile time. C has
this useful ability when placing string literals lexically next to one another,
but this needs to be handled at the syntax extension level to recursively expand
macros.

The major use case for this is something like:

    macro_rules! mylog( ($fmt:expr $($arg:tt)*) => {
        error2!(concat!(file!(), ":", line!(), " - ", $fmt) $($arg)*);
    })

Where the mylog macro will automatically prepend the filename/line number to the
beginning of every log message.
Diffstat (limited to 'src/libsyntax/ext/expand.rs')
-rw-r--r--src/libsyntax/ext/expand.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 052b177d4d8..ba946d5fb1f 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -1083,7 +1083,7 @@ struct NoOpFolder {
 
 impl ast_fold for NoOpFolder {}
 
-struct MacroExpander {
+pub struct MacroExpander {
     extsbox: @mut SyntaxEnv,
     cx: @ExtCtxt,
 }