Current macro definition is not easily re-exportable
Closed this issue · 3 comments
Refer this line:
Line 49 in da9f1a4
The use of ::ruint
means that re-export (e.g. here) breaks unless the user of the re-exported macro also has ruint
in their top-level module hierarchy (which suggests they need to add to Cargo.toml
and breaks the point of the re-export).
I'm opening this issue to discuss possible fixes. I haven't verified this but I think just using $crate::
in lieu of ::ruint
will fit the bill (cf. https://doc.rust-lang.org/1.5.0/book/macros.html#the-variable-crate). Otherwise I think ruint
by itself would also work as then we could just use re_exporter::{ruint, uint};
(which is not as nice but is better IMO than adding the explicit ruint
dependency and possible in alloy_primitives
).
If we find a solution we like, I'm happy to open a PR.
@DaniPopes cc
to make this concrete, we ran into this here:
with the change required to Cargo.toml
here: ralexstokes/ethereum-consensus@b703074#diff-0219ba3c813ee31a0ca2d8c440d9f100c5e53b68a57ec2f57f73e36032511d59R18
I'm opening this issue to discuss possible fixes. I haven't verified this but I think just using $crate:: in lieu of ::ruint will fit the bill (cf. https://doc.rust-lang.org/1.5.0/book/macros.html#the-variable-crate).
The specal $crate
variable only works in declarative macros, while the uint!
macro is a procedural macro. So it's not as simple as swapping it out. The proc macro is effectively codegen. We have to design some clean code that achieves this
It seems bad for the ruint-macro
crate to get a redesign to support sideloading the ruint
types that it relies on from other crates.
In the meantime, adding ruint
to your dependencies is the correct workaround, and we'll document this workaround in the primitives library