Macros and compiler plugin conflicts


#1

I want to develop a compiler plugin to annotate the rust code. So I hope to define a global attribute like #![test].

My code runs well with single functions with #[check], however, when it comes to applying it to all the items it is declared with, #![check], it prompts with errors resulting from several macros. The plugin is a syntax extension.

The demo code from my code:

#![feature(plugin)]
#![plugin(myplugin)]
#![check]

struct AA {
    x: i32,
}

macro_rules! hello_AA {
    () => ( AA {x: 3});
}  

fn main() {
    let x = hello_AA!();
    println!("x.x = {}",x.x);
}

The code failed with errors.

error: cannot find macro `hello_AA!` in this scope
  --> src/main.rs:21:13
   |
21 |     let x = hello_AA!();
   |             ^^^^^^^^
   |
   = help: have you added the `#[macro_use]` on the module/import?

It seems the macros is not expanded properly when the plugin runs.