@@ -242,8 +242,22 @@ fn handle_type<'a, T: TypeHandler<'a>>(
242242 #into_type
243243 } ) )
244244}
245+ fn is_c_style_enum ( data : & DataEnum ) -> bool {
246+ /*
247+ * TODO: Should the following be considered a 'c-style' enum?
248+ * enum Test {
249+ * One,
250+ * Two { },
251+ * Three( )
252+ * }
253+ *
254+ * Right now it *is*, because `fields.is_empty`,
255+ * although we could require them all to be unit-variants (like `One`)
256+ */
257+ data. variants . iter ( ) . all ( |var| var. fields . is_empty ( ) )
258+ }
245259fn enum_static_type ( data : & DataEnum , name : & Ident ) -> Result < TokenStream , syn:: Error > {
246- if data . variants . iter ( ) . all ( |var| var . fields . is_empty ( ) ) {
260+ if is_c_style_enum ( data ) {
247261 // C-style enum
248262 // TODO: Strict typing
249263 // TODO: Should we always assume that we're unsigned?
@@ -451,11 +465,11 @@ impl<'a> TypeHandler<'a> for UnionTypeHandler<'a> {
451465 }
452466
453467 fn type_def_type ( ) -> TokenStream {
454- quote ! ( static_reflect:: types:: UnionDef )
468+ quote ! ( static_reflect:: types:: UntaggedUnionDef )
455469 }
456470
457471 fn def_into_type ( def_ref : TokenStream ) -> TokenStream {
458- quote ! ( static_reflect:: types:: TypeInfo :: Union ( #def_ref) )
472+ quote ! ( static_reflect:: types:: TypeInfo :: UntaggedUnion ( #def_ref) )
459473 }
460474
461475 fn handle_fields < F : FnMut ( FieldInfo < ' a > ) > ( & mut self , mut handler : F ) -> syn:: Result < ( ) > {
@@ -498,7 +512,7 @@ impl<'a> TypeHandler<'a> for UnionTypeHandler<'a> {
498512 quote ! ( {
499513 use std:: mem:: { size_of, align_of} ;
500514 #header
501- let def = UnionDef {
515+ let def = UntaggedUnionDef {
502516 name: stringify!( #name) ,
503517 fields: _FIELDS,
504518 size: size_of:: <#name>( ) ,
0 commit comments