How to import macro from external crate? Crate is imported in Cargo.toml, used #[macro_export] before macro, used #[macro_use(macro_name)] before importing crate in code. But i am always getting this error: (i hate 4 spaces, because it's too hard to use them to highlight code. So, no code block. Just plain text)
ancient@lnotebook:~/helium/helium_test$ cargo clean && cargo build
Compiling helium v0.1.0 (file:///home/ancient/helium/helium#6e231afe)
Compiling helium_test v0.1.0 (file:///home/ancient/helium/helium_test)
src/main.rs:2:13: 2:18 error: imported macro not found [E0469]
src/main.rs:2 #[macro_use(he_mk)]
^~~~~
error: aborting due to previous error
Could not compile helium_test.
To learn more, run the command again with --verbose.
should give you a plain text block. It's still readable, so no worries, but now you know,
As for your problem, it's hard to say exactly what's going on without a code sample, but just to be sure, are the macros defined in a module? If that's the case, then you will have to add #[macro_use] to that module as well:
ancient@NickolayPC:~/code/tests/helium_test/src$ cargo clean && cargo build
Compiling helium v0.1.0 (file:///home/ancient/git/helium/#6e231afe)
Compiling helium_test v0.1.0 (file:///home/ancient/code/tests/helium_test)
main.rs:1:13: 1:18 error: imported macro not found [E0469]
main.rs:1 #[macro_use(he_mk)]
^~~~~
error: aborting due to previous error
Could not compile `helium_test`.
To learn more, run the command again with --verbose.
This is not your current problem, but macros do not currently use the module namespace system, and :: in macro names means nothing. Once you get import working, it'll just be he_mk!, no qualifier.
Stupid question, but that version of lib.rs lacks #[macro_export], which would seem to be why it's not exporting the macro. Is it possible you're having Cargo.lock problems?