Real life scenario:
I wanted to use crate::app::verbose_trace!("string literal")
inside crate::app::args::parse
module.
Reproducable scenario:
After an hour of attempts, I came with following simple example. It exposes my misunderstanding of macros.
#[macro_use]
mod foo{
pub fn bar(){
println!("bar works")
}
#[macro_export]
macro_rules! baz{
()=> {println!("baz works")}
}
}
fn main(){
foo::bar();
foo::baz!();
// Following doesn't work either:
// use foo::baz;
// baz!();
}
Compiler complains
error[E0433]: failed to resolve: could not find `baz` in `foo`
--> src\main.rs:14:14
|
14 | foo::baz!();
| ^^^ could not find `baz` in `foo`
as if it was utterly blind :0
I read:
I would like to see:
- A compilable version of my example.
- Explanations why it did failed to compile.
- Optionally:
- Some other suggestions how to use marco in submodule/supermodule.