Question

When I'm trying to define a macro in code, compiler says this:

refix/mod.rs:12:1: 12:12 error: macro definitions are not stable enough for use and are subject to change
refix/mod.rs:12 macro_rules! re_fix(
                ^~~~~~~~~~~
refix/mod.rs:12:1: 12:12 note: add #[feature(macro_rules)] to the crate attributes to enable
refix/mod.rs:12 macro_rules! re_fix(

I've added a lot of #[feature(macro_rules)], but it didn't help.

Source code: https://gist.github.com/suhr/11207656

PS: yes, they're probably a lot of other errors there, but I am interested about this one.

Was it helpful?

Solution

I think that error message is somewhat misleading. You have to add #![feature(macro_rules)] to your main crate module (note the exclamation sign), along with #![crate_id=...] and others.

#![crate_id="rsfix#0.0"]
#![feature(macro_rules)]

macro_rules! example( ... )

fn main() {
    example!(...);
}

This should work on the latest compiler version.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top