You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is - generated code is still trying to import modules from serde, not from your_new_crate.
I suggest wrap "expand_derive_serialize"(or something) in
pub fn derive_serialize(input: TokenStream) -> TokenStream {
let mut input = parse_macro_input!(input as DeriveInput);
ser::expand_derive_serialize(&mut input)
.unwrap_or_else(syn::Error::into_compile_error)
.into()
}
into new public function, something like
"expand_derive_serialize_WITH_PATH_TO_CRATE"
with additional(maybe few) parameters what change all serde occcurences to parameter value.
Of course defalut would be just serde.
For example new implementation would be
pub fn derive_serialize(input: TokenStream) -> TokenStream {
let mut input = parse_macro_input!(input as DeriveInput);
ser::expand_derive_serialize_WITH_PATH_TO_CRATE(&mut input, "serde")
.unwrap_or_else(syn::Error::into_compile_error)
.into()
}
and you can write something like
let generated_serialize_token_stream_for_something_struct = serde::expand_derive_serialize_WITH_PATH_TO_CRATE(&mut possible_something_struct_token_stream, "your_crate");
Well i can write implemenation mannualy in my macro but in time i think it will be outdated i just wont know about some vulnerability or new optimization.
The text was updated successfully, but these errors were encountered:
imagine you creating new crate what depends on serde and reexport it
pub use serde::*;
In your crate you creating a new proc_macro. In proc macro you creating something like
The problem is - generated code is still trying to import modules from
serde
, not fromyour_new_crate
.I suggest wrap "expand_derive_serialize"(or something) in
into new public function, something like
"expand_derive_serialize_WITH_PATH_TO_CRATE"
with additional(maybe few) parameters what change all
serde
occcurences to parameter value.Of course defalut would be just
serde
.For example new implementation would be
and you can write something like
let generated_serialize_token_stream_for_something_struct = serde::expand_derive_serialize_WITH_PATH_TO_CRATE(&mut possible_something_struct_token_stream, "your_crate");
Well i can write implemenation mannualy in my macro but in time i think it will be outdated i just wont know about some vulnerability or new optimization.
The text was updated successfully, but these errors were encountered: