Closed lilyball closed 3 years ago
As far as I understand, this is not possible now (see discussion and links in https://github.com/rust-lang/rust/issues/54363) There seems to be a workaround in https://github.com/rust-lang/rust/issues/54647 but I haven't tested it.
Hack idea: make oid!()
a macro-by-example in der_parser
that just invoked something like _oid!($crate, $($args)*)
and have the proc macro be _oid!()
. Hopefully this will pass the crate path in correctly so the proc macro can then use it in the generated code.
Maybe this hack could be the solution...
format!(
"{{
use der_parser::oid;
use der_parser::oid::Oid;
// this will be the ret value
der_parser::oid::Oid::new(alloc::borrow::Cow::Borrowed(&{}))}}",
s
)
I'm working on this, and will try to find a solution for 6.0.
Workaround: import the re-exported der-parser
:
use x509_parser::der_parser;
let oid = der_parser::oid!{ 1.2.3.4 };
The
oid!
macro evaluates to a reference toder_parser::…
. This doesn't work if I don't have the crate in my namespace, e.g. if I'm using the macro viause x509_parser::der_parser::oid;
. If this was amacro_rules!
macro I'd say it needs to be using$crate
, I hope proc macros have an equivalent (heck, can they just use$crate
directly too?).