File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -48,14 +48,6 @@ impl<'a> Input<'a> {
4848 . map ( |variant| Data :: from_variant ( ident, & derive_wheres, variant) )
4949 . collect :: < Result < Vec < Data > > > ( ) ?;
5050
51- // Empty enums aren't allowed.
52- if variants. iter ( ) . all ( |variant| match variant. fields ( ) {
53- Either :: Left ( fields) => fields. fields . is_empty ( ) ,
54- Either :: Right ( _) => true ,
55- } ) {
56- return Err ( Error :: item_empty ( span) ) ;
57- }
58-
5951 // Find if a default option is specified on a variant.
6052 let mut found_default = false ;
6153
@@ -80,6 +72,15 @@ impl<'a> Input<'a> {
8072 return Err ( Error :: default_missing ( span) ) ;
8173 }
8274
75+ // Empty enums aren't allowed unless they implement `Default`.
76+ if !found_default
77+ && variants. iter ( ) . all ( |variant| match variant. fields ( ) {
78+ Either :: Left ( fields) => fields. fields . is_empty ( ) ,
79+ Either :: Right ( _) => true ,
80+ } ) {
81+ return Err ( Error :: item_empty ( span) ) ;
82+ }
83+
8384 Item :: Enum { ident, variants }
8485 }
8586 syn:: Data :: Union ( data) => {
You can’t perform that action at this time.
0 commit comments