Macro expansion can lead to programs that don't typecheck, unless a very restrictive typing system is used (e.g. MetaML, MetaOcaml). I don't think Rust has such restrictions, therefore I assume that type-checking happens after macro expansion.
It does, but what I was getting at was that full compilation doesn't need to occur first. Macro expansion is one of the very first phases of compilation (and doesn't have access to typechecking information, incidentally).
Not in Rust 1.0. In the nightlies there are syntax extensions available that give you more power, but those are likely to see significant revisions before they're available in a stable version since they're a major backwards compatibility hazard.
Not something being actively worked on, but I and some others care about it.
Rust macro-esque things are of three types:
- Macro by Example (MBE): These are easily defined by the user via `macro_rules!`, which can match on their input and expand to some output at compile time. These don't need to be defined as a plugin; you can define a macro directly in your code.
- tokentree expansion plugins: These take in a token tree, run arbitrary code, and output an AST (syntax tree) node. Ish.
- AST expansion plugin: These take in the parsed AST, run arbitrary code, and output another AST to replace or augment it.
There also is support for custom lints and llvm passes.
I'm not sure who specifically is working on improving the macro system, but it's definitely something that's been prioritized. My primary recommendation for contacting the relevant people would be either the Rust internals forums (https://internals.rust-lang.org) or the #rust-internals channel on irc.mozilla.org.