Warn about #[macro_export] mod m? #52371
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-macros-1.2
Area: Declarative macros 1.2
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I haven't used macros that often, but had to make changes in a 3rd party project.
During refactoring I tried to import macros from another module. I knew I had to add
macro_use
,macro_export
somehow, but couldn't remember details.While
rustc
was somewhat helpful in warning me on my first attempt:It did not warn me about doing this:
where in reality I should have done that:
This was particularly confusing since the used macro was a few modules down in the hierarchy, and I should have done
#[macro_use]
on each level. Since I wasn't warned, I assumed#[macro_export] mod m;
was correct. Instead, I tried a few permutations adding#[macro_use]
to other places, which all didn't work out.Two things that would have worked for me:
#[macro_export] mod m;
macro_use
needs to be added to all parent modules (maybe with a link to the error index)Update: using
rustc 1.29.0-nightly (9fd3d7899 2018-07-07)
The text was updated successfully, but these errors were encountered: