A very confusing macro visibility issue
⚓ Rust 📅 2025-10-10 👤 surdeus 👁️ 3This is absolutely bizarre:
For an executable's integration tests that originally had no lib.rs , since integration tests require use but cannot directly use main , we created a lib.rs and moved all of main 's submodules into it—essentially making main obsolete.
The strange thing is, we had a macro defined in main that was also moved to lib . Through use super::* , submodules could call the macro. But later, when we added another one, we found it couldn't be located no matter what.
After struggling for a long time, we discovered that we needed to add it in main as well—as if it was using the definition from main .
Then, as an experiment, we commented out the one in lib.rs and found it also threw an error, indicating that it was also using the one from lib.rs ...
So, what is the reason???
5 posts - 3 participants
🏷️ Rust_feed