[rust-dev] Exporting macros: #[macro_escape] usage

Vladimir Matveev dpx.infinity at gmail.com
Fri Jan 10 14:46:54 PST 2014


As far as I understand, the current way to export macros is to
annotate the module with macro_rules definition with #[macro_escape]
annotation. But I just can't get it right, and my macro is not visible
in other module :(

Here is what I have:

----- START -----

pub mod m1;


pub mod submod;

macro_rules! example_rule(
    () => (mod test;)

use m1;

----- END -----

I have assumed that putting #[macro_escape] annotation to a module
makes all macros from that module available in all modules which
import this module, but apparently I'm wrong because the code above
does not work with 'macro undefined' error.

Could please someone explain how #[macro_escape] works in detail? I
couldn't find any documentation on it, and looking through standard
libs was not helpful.


More information about the Rust-dev mailing list