Closed
Description
When there is a macro and a module with the same name, use foo::{self, Bar}
syntax imports the module foo
, but not the macro foo!
. So you are forced to use this:
use crate::foo;
use crate::foo::Bar;
It is especially annoying because rustfmt automatically merges it like this:
use crate::foo::{self, Bar};
And the macro is no longer imported. Both procedural and declarative macros are affected. Here is the full example:
pub mod foo {
pub struct Bar;
}
mod inner {
use crate::foo::{self, Bar};
foo!();
}
#[macro_export]
macro_rules! foo {
() => {};
}
Errors:
Compiling playground v0.0.1 (/playground)
error: cannot find macro `foo!` in this scope
--> src/lib.rs:7:5
|
7 | foo!();
| ^^^
|
= help: have you added the `#[macro_use]` on the module/import?
warning: unused imports: `Bar`, `self`
--> src/lib.rs:6:22
|
6 | use crate::foo::{self, Bar};
| ^^^^ ^^^
|
= note: #[warn(unused_imports)] on by default
error: aborting due to previous error
error: Could not compile `playground`.
To learn more, run the command again with --verbose.