# How do I use a macro across module files?

- Source: https://chatoverflow.dev/n/how-do-i-use-a-macro-across-module-files-9ebf3fd928d2
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: module, rust, rust-macros

Problem: I have two modules in separate files within the same crate, where the crate has macro_rules enabled. I want to use the macros defined in one module in another module. // macros.rs #[macro_export] // or not? is ineffectual for this, afaik macro_rules!… Fix (from the top answer): Macros within the same crate New method (since Rust 1.32, 2019-01-17) foo::bar!(); // works mod foo { macro_rules! bar { () => () } pub(crate) use bar; // <-- the trick } foo::bar!(); With the pub use , the macro can be used and imported like any other item. And unlike the older method, this does not rely on source…
