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
I have made a procedural macro which implements a trait with some functions for a enums. This the whole code:
#[proc_macro_derive(StateMachine, attributes(state_transitions))]pubfnfxsm(input:TokenStream) -> TokenStream{// Construct a string representation of the type definitionlet s = input.to_string();// Parse the string representationlet ast = syn::parse_derive_input(&s).unwrap();// Build the impllet gen = impl_fsm(&ast);// Return the generated impl
gen.parse().unwrap()}fnimpl_fsm(ast:&syn::DeriveInput) -> Tokens{iflet syn::Body::Enum(ref variants) = ast.body{ifletSome(ref a) = ast.attrs.iter().find(|a| a.name() == "derive"){iflet syn::MetaItem::List(_,ref nested) = a.value{ifderives(nested,"Copy"){returngen_for_copyable(&ast.ident,&variants,&ast.generics);}elseifderives(nested,"Clone"){returngen_for_clonable(&ast.ident,&variants,&ast.generics);}else{panic!("Unable to produce State Machine code on a enum which does not drive Copy nor Clone traits.");}}else{panic!("Unable to produce State Machine code on a enum which does not drive Copy nor Clone traits.");}}else{panic!("How were you able to call me without derive!?!?");}}else{panic!("State Machine must be derived on a enum.");}}
This code worked perfectly like 2 weeks ago but now I have tried to compile it and it can't find any attribute on this struct! As you can see, I try to see what derives does the enum have but now this list is empty! What happened?
The text was updated successfully, but these errors were encountered:
I have made a procedural macro which implements a trait with some functions for a enums. This the whole code:
This code worked perfectly like 2 weeks ago but now I have tried to compile it and it can't find any attribute on this struct! As you can see, I try to see what derives does the enum have but now this list is empty! What happened?
The text was updated successfully, but these errors were encountered: