]> git.lizzy.rs Git - rust.git/commit
Implement a concat!() format extension
authorAlex Crichton <alex@alexcrichton.com>
Sun, 6 Oct 2013 04:15:46 +0000 (21:15 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 31 Oct 2013 20:46:10 +0000 (13:46 -0700)
commita49e65c2edad450cabc0745e94e7c031c5d4f7f8
treed63f71dcbb24a4f7f74e60d4e06dd1779e823a0c
parente976de32dc590f759e6c0c72d286844ca373e775
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.
doc/rust.md
src/libsyntax/ext/base.rs
src/libsyntax/ext/concat.rs [new file with mode: 0644]
src/libsyntax/ext/expand.rs
src/libsyntax/ext/format.rs
src/libsyntax/syntax.rs
src/test/compile-fail/concat.rs [new file with mode: 0644]
src/test/run-pass/concat.rs [new file with mode: 0644]