Pre-RFC: first-class support for compile-to-Rust languages

An interface generating TokenStream instead of text files with #line would be nicer indeed.

However, the current procedural macros aren’t great for it, since they must be explicitly invoked from a regular Rust file.

Since you wouldn’t want to create a boilerplate .rs file for every .non-rs file, the macro would have to parse and emit the whole project in one go. That’s not too bad if you want to replace the module system:

lib.rs:

#![feature(proc_macro)]
extern crate rust_coffee;
use rust_coffee::start;
start!();

but if your goal was to make “like Rust, but with a new feature” language, then that would be a bit annoying. You’d probably want ability for rustc to invoke a proc_macro on every file it is about to parse.

1 Like