Here is sample code
mod foo {
macro_rules! bar {
() => { println!("123") };
}
}
use crate::foo::bar;
fn main() {
bar!();
}
Which build fails with
error[E0432]: unresolved import `crate::foo::bar`
--> src/main.rs:7:5
|
7 | use crate::foo::bar;
| ^^^^^^^^^^^^^^^ no `bar` in `foo`
error: cannot determine resolution for the macro `bar`
--> src/main.rs:10:5
|
10 | bar!();
| ^^^
|
= note: import resolution is stuck, try simplifying macro imports
Since 2018 introduces modules clarification I expected this code to work normally. But it seems that use crate::macro
only works for topmost macros declared in other crates. I was sure that macro_use
and so on are obsolete and completely replaced by simple use
, but it seems that it's not the case.