Allow specifying a `crate` root in the automock proc macro.
There's a lot of hardcoded ::mockall in the crate.
It makes it very difficult to use it in some common crate as users of this common crate need to also pull in mockall.
It should work very similar to how serde does it. https://serde.rs/container-attrs.html#crate
Are you talking about some kind of transitive dependency? Can you provide an example that demonstrates your problem?
More or less.
We have a common crate that we use to work with tonic, and in that common crate, we have a macro used to generate a lot of the boilerplate we need.
We generate some stuff, including a Client trait.
On that trait, we slap a #[cfg_attr(any(test, feature = "mock"), $crate::export::mockall::automock)]
This gives us the ability to use all the amazing features of mockall.
We need to invoke that macro with the context of the callee crate.
Ideally, this crate just needs to pull in our common library, and we'll handle stuff for it.
But because mockall uses ::mockall, we still have to pull in mockall.
Common crate:
#[macro_export]
macro_rules! client {
(
impl $trait_:ident for $client:ident {
$(
fn $fn_name:ident($req_ty:path) -> $resp_ty:path;
)*
}
) => {
#[cfg_attr(any(test, feature = "mock"), $crate::export::mockall::automock)]
pub trait $trait_ {}
};
)
Crate 1:
// mockall will generate the mock here. (`::mockall`)
// but this crate might not have the mockall dependency.
common_crate::client! {
...
}
I hope that clarifies it. :D
And what change are you looking for? Can you show an example of how you would like to use this new feature?