Closed eduardosm closed 1 year ago
Thanks for proposing the fix! Do you think it's better to re-export the macro in the meta crate with alias? (e.g. use dashu_macro::ubig_embedded as ubig
), by this way we can move all the documentation into the dashu-macro
crate.
Besides, this will require a major version bump. I have a plan to publish a v0.3.1 version, so it will be merged after that.
Moving documentation to the dashu-macros
crate for the embedded macros will cause doc-tests to fail because it won't find the dashu
crate.
/// For numbers that are small enough (fits in a [u32]), the literal can
/// be assigned to a constant.
///
/// ```
/// use dashu::{ibig, integer::IBig};
///
/// const A: IBig = ibig!(-123);
/// const B: IBig = ibig!(0x123);
/// const C: IBig = ibig!(-0xffff_ffff);
/// ```
---- src/lib.rs - dbig_embedded (line 273) stdout ----
error[E0433]: failed to resolve: use of undeclared crate or module `dashu`
--> src/lib.rs:274:5
|
3 | use dashu::{ibig, integer::IBig};
| ^^^^^ use of undeclared crate or module `dashu`
And we cannot make dashu-macros
depend on dashu
because it would create a cyclic dependency between dashu
and dashu-macros
.
I think it's a very clever fix! Thanks!
v0.3.1 is released, and the next planned version is v0.4. So I fixed some conflicts and merged this PR, thanks for your contribution!
Currently, building with
will make the build fail.
--all-targets
means that tests are also compiled (but not run) and--workspace
means that all the crates of the workspace are compiled. This caused thedashu-macros
crate to be compiled with theembedded
feature enabled, which caused tests to fail to compile (because it was looking for types indashu::*
instead ofdashu_*
).There are other situations that could trigger this issue. If you had some crate
A
that depends ondashu-macros
,dashu-int
andB
.B
is another crate that depends ondashu
, so it will pulldashu-macros
with theembedded
feature enabled, causing macros to fail in crateA
.To fix this, the
embedded
feature flag is removed and there are now two variants for each macro, a non-embedded one and an embedded one. The non-embedded variants are visible in in thedashu-macros
crate and the embedded variants are hidden indashu-macros
and re-exported in thedashu
crate.