1- use darling:: FromDeriveInput ;
21use proc_macro2:: TokenStream ;
32use quote:: ToTokens ;
43use syn:: { spanned:: Spanned , Data , DeriveInput , Error , Result } ;
54
65use crate :: {
76 attrs:: container:: ContainerAttributes ,
8- gen:: { venum :: VersionedEnum , version:: ContainerVersion , vstruct:: VersionedStruct } ,
7+ gen:: { version:: ContainerVersion , vstruct:: VersionedStruct } ,
98} ;
109
1110pub ( crate ) mod field;
1211pub ( crate ) mod neighbors;
13- pub ( crate ) mod venum;
1412pub ( crate ) mod version;
1513pub ( crate ) mod vstruct;
1614
@@ -26,20 +24,13 @@ pub(crate) mod vstruct;
2624// TODO (@Techassi): Think about how we can handle nested structs / enums which
2725// are also versioned.
2826
29- pub ( crate ) fn expand ( input : DeriveInput ) -> Result < TokenStream > {
30- // Extract container attributes
31- let attributes = ContainerAttributes :: from_derive_input ( & input) ?;
32-
33- // Validate container shape and generate code
27+ pub ( crate ) fn expand ( attrs : ContainerAttributes , input : DeriveInput ) -> Result < TokenStream > {
3428 let expanded = match input. data {
35- Data :: Struct ( data) => {
36- VersionedStruct :: new ( input. ident , data, attributes) ?. to_token_stream ( )
37- }
38- Data :: Enum ( data) => VersionedEnum :: new ( input. ident , data, attributes) ?. to_token_stream ( ) ,
39- Data :: Union ( _) => {
29+ Data :: Struct ( data) => VersionedStruct :: new ( input. ident , data, attrs) ?. to_token_stream ( ) ,
30+ _ => {
4031 return Err ( Error :: new (
4132 input. span ( ) ,
42- "derive macro `Versioned ` only supports structs and enums " ,
33+ "attribute macro `versioned ` only supports structs" ,
4334 ) )
4435 }
4536 } ;
0 commit comments