-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error ‘could not find derive_more in the list of imported crates’ when re-exporting macros #338
Comments
Why are you re-exporting the macros like this? I'm inclined to think that this is not really a supported usecase. I think you can solve the error by adding To be clear, this was originally introduced to fix: #180 In theory we could reference the traits from core again, instead of from derive_more. But that would only work for including the traits. So the generated code would still fail to compile for derives that create any of the error structs: https://docs.rs/derive_more/1.0.0-beta.6/derive_more/index.html#structs |
It is really convenient in my case, and it worked fine with previous version 0.99.17, so I didn't expect I'll have problems after update :(
Unfortunately, it didn't work.
Didn't encounter it so far, probably because I use only numeric derives for regular structs. |
We could also use use my_derive::{derive_more, Add, Sub, Mul, Div, AddAssign, SubAssign, MulAssign, DivAssign};
#[derive(Add, Sub, Mul, Div, AddAssign, SubAssign, MulAssign, DivAssign)]
pub struct Factor(pub f64);
// expanding to `derive_more::core::ops::Add` will work now This way is not ideal, but at least we provide an option for such re-exports at all. On the other hand, I don't see any practical downsides for us if we'd do
Some old, not yet refactored, code. Eventually, will be remade too. |
Does adding |
@JelteF no, unfortunately, it doesn't work if the I was thinking about this too, and wondered why Rust doesn't allow this. Then I realized that due to version requirements and resolution, there can be multiple |
@tyranron I don't really like doing this. It makes our generated code less hygenic.
@YuliaProkopovych could you clarify why it is convenient? I'm currently leaning towards the position: "we cannot reasonbly support this usecase with the new design where we need to import error types from the derive_more crate". If you can clarify why you are are trying to do this in the first place, maybe I change my mind. |
My point is that it's very unlikely for people to have |
Yeah, maybe it's uncommon enough for people to have that not to care. But honestly I thought the same about people using "core" as their package name or re-exporting the derives from derive_more. I don't think handling all is possible, so I'm trying to understand which usecases actually make sense to support and which don't. |
I have a crate where I put together commonly used derive macros, like the ones I mentioned, some derives from Unfortunately using |
@YuliaProkopovych Would this be an acceptable workaround for you? i.e. Requiring to re-export and then also |
Would be wonderful ❤️ |
Yes, absolutely. Thank you! |
@tyranron okay let's do your suggestion then. And we should also update the path of AddAssign to include from derive_more. |
…338) ## Synopsis At the moment, the `derive_more` macros cannot be re-exported or the `derive_more` crate cannot be renamed as the dependency, because expansions require `::derive_more` module be present in the scope. See #338 for details. ## Solution Use `derive_more::*` paths instead of `::derive_more::*` in expansions, allowing to provide this module in the scope on the call site even when `derive_more` is transitive dependency of the crate.
Hi,
I have local lib crate that uses
derive_more
and re-exports its macros.Then I import my lib with re-exported macros into another crate that uses them:
But I get following error :
As I see, currently
Add, Sub, Mul, Div
macros use path to trait that starts with::derive_more::
which doesn’t resolve after re-export.
derive_more/impl/src/utils.rs
Line 380 in a7116ad
It would be great if macros used a path that resolves after re-export.
The text was updated successfully, but these errors were encountered: