It has no meaning "at the top", but more specifically "right before mod error;" has meaning. By default macros are scoped to their module, but #[macro_use] will let it escape to the parent context, including all submodules from there.
By the way, #[macro_use] is now a bit obsolete, since classic pathing can be used with macros provided they get re-exported at their definition site; which has the advantage of being consistent with the rest of the language's items. For more info, see:
Thanks, this seems to be nicer. When I tried it, the macro works but cargo clippy reports a warning like this:
warning: this import is redundant
--> src/error.rs:50:1
|
50 | pub(crate) use foo;
| ^^^^^^^^^^^^^^^^^^^^^ help: remove it entirely
|
= note: `#[warn(clippy::single_component_path_imports)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_component_path_imports
This warning seems not valid to me. Is this a clippy bug? or should I fix my code?