Hi everyone,
I have an issue with cyclic dependency. My main crate is published on crates.io and it has proc-macro, which is published as separate crate. This proc-macro I also want to use in some my another projects, but the issue is that proc-macro is depends on main crate's traits:
pub struct Imports {
pub binary_converter: TokenStream2,
// ...
pub stream_reader: TokenStream2,
}
impl Imports {
pub fn get() -> Self {
Self {
binary_converter: quote!(crate::traits::BinaryConverter),
// ...
stream_reader: quote!(crate::traits::StreamReader),
}
}
}
and I want to replace it with:
pub struct Imports {
pub binary_converter: TokenStream2,
// ...
pub stream_reader: TokenStream2,
}
impl Imports {
pub fn get() -> Self {
Self {
binary_converter: quote!(tentacli::traits::BinaryConverter),
// ...
stream_reader: quote!(tentacli::traits::StreamReader),
}
}
}
For this purpose I set my main crate as a dependency for proc-macro:
[lib]
name = "idewave_packet"
path = "src/lib.rs"
proc-macro = true
[dependencies]
# https://github.com/dtolnay/proc-macro-workshop#debugging-tips
syn = { version = "2.0.49", features = ["full"] }
quote = "1.0"
proc-macro2 = "1.0"
structmeta = "0.3.0"
tentacli = "8.0.7"
and published next patch version of proc-macro on crates.io. But on build I got this error:
error: cyclic package dependency: package `idewave_packet v1.3.1` depends on itself. Cycle:
package `idewave_packet v1.3.1`
... which satisfies dependency `idewave_packet = "^1.3.0"` of package `tentacli v8.0.7`
... which satisfies dependency `tentacli = "^8.0.7"` of package `idewave_packet v1.3.1`
Could somebody advice, how can this be fixed ? The only idea I have is to push traits and types into separate crate (and I would like to avoid this, since tentacli
already provides all of this).