Additional useful compiler macros

I’d like the macros current_path! and stuff like that.

Example usage would be in other macros such that:

myrust! {
mod foo;

can actually expand to the following:

mod foo {
contents of

This would be useful to remove most of the compiler and instead implement everything as variations of a large macro. recursively invoke a macro for submodules, such that the macro matches the contents of the submodule.

Not only would you be able to write rust with optional semicolons, define foo! as sugar for into, etc, but you’d be able to do different things for different crates and they’d all compile on stable rust!

You get all the benefits of fragmentation (innovation, best tool for the job, etc) with none of the drawbacks (it’s still Rust no matter how non-rust-like it looks).

Things like NLLs and match ergonomics would still need to be part of the compiler, but things like tryfn and stuff would no longer be built-in!

1 Like

What would this provide over a module level proc macro annotation? e.g.

mod foo {

It isn’t proc macros - it would work on stable.

The whole point is the ability to automatically propagate into submodules.

Proc macros will be stable in 1.30, which will be released next week!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.