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> {
48
48
. map ( |variant| Data :: from_variant ( ident, & derive_wheres, variant) )
49
49
. collect :: < Result < Vec < Data > > > ( ) ?;
50
50
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
-
59
51
// Find if a default option is specified on a variant.
60
52
let mut found_default = false ;
61
53
@@ -80,6 +72,15 @@ impl<'a> Input<'a> {
80
72
return Err ( Error :: default_missing ( span) ) ;
81
73
}
82
74
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
+
83
84
Item :: Enum { ident, variants }
84
85
}
85
86
syn:: Data :: Union ( data) => {
You can’t perform that action at this time.
0 commit comments