Rust now has the ability to import macros from other crates, hurray!
However, I'd like to propose adjusting the current way of using them to be
more like importing/exporting other symbols of a crate.

1) It's more consistent, makes it easier to find where macros came from.
2) Current usage brings name collisions.


Current example:

    pub mod foo {
      // assume other macros as well
      #[macro_export]
      macro_rules! bar ( ... )
    }

    pub mod baz {
      // assume other macros as well
      #[macro_export]
      macro_rules! bar ( ... )
    }

    mod herp {
      // i want bar! from foo, and some other macros from baz
      [phase(syntax)]
      use super::foo;
      [phase(syntax)]
      use super::baz;

      pub Derp = bar!(); // which bar? is this an ICE? or logic error?
    }

Proposed example:

    pub mod foo {
      pub marco_rules! bar ( ... );
    }

    pub mod baz {
      pub marco_rules! bar ( ... );
      pub marco_rules! quux ( ... );
    }

    mod herp {
      use super::foo::bar!;
      use super::baz::quux!;
      // using same name macros, no problem
      use baz! = super::baz::bar!;

      pub Derp = bar!(baz!());
    }
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to