Closed
Description
Attempting to compile the following example code fails with an error:
macro_rules! b3{ ( band $x:ident ) => ( static $x : int = 3i; ) }
macro_rules! b4{ ( bind $x:ident ) => ( static $x : int = 4i; ) }
#[cfg(stage0)]
b3!(band x)
#[cfg(not(stage0))]
b4!(bind x)
fn main() { io::println(fmt!("Hello world: %?", x)); }
The error:
% rustc /tmp/m.rs
/tmp/m.rs:5:0: 5:2 error: attrs on macros are not yet supported
/tmp/m.rs:5 b3!(band x)
^~
We should support such attributes. Here are some motivations:
- As illustrated by the above example, it is difficult to migrate from one macro definition form in the snapshot rustc to a newer form in the development rustc, because you cannot annotate macro invocations with the usual
#[cfg(stage0)]
and#[cfg(not(stage0)]
. - One cannot put documentation comments on macros (which I believe are represented as attributes within the compiler internally; if this is not true, then this needs to be a separate issue ticket).