@@ -47,15 +47,10 @@ impl MacroSelectionConfig {
4747 pub fn extend_idents ( & mut self , iter : impl IntoIterator < Item = syn:: Ident > ) {
4848 self . idents . extend ( iter) ;
4949 }
50-
51- pub ( crate ) fn idents ( & self ) -> & [ syn:: Ident ] {
52- & self . idents
53- }
5450}
5551
5652pub ( crate ) type EnumExcludeConfig = MacroSelectionConfig ;
5753pub ( crate ) type VariantExcludeConfig = MacroSelectionConfig ;
58- pub ( crate ) type VariantIncludeConfig = MacroSelectionConfig ;
5954
6055#[ derive( Clone , Default ) ]
6156pub ( crate ) struct EncapsulateEnumConfig {
@@ -84,56 +79,26 @@ pub(crate) struct VariantConfig {
8479 // #[enumcapsulate(exclude(…))]
8580 pub exclude : Option < VariantExcludeConfig > ,
8681
87- // #[enumcapsulate(include(…))]
88- pub include : Option < VariantIncludeConfig > ,
89-
9082 // #[enumcapsulate(field(…))]
9183 pub field : Option < VariantFieldConfig > ,
9284}
9385
9486impl VariantConfig {
95- pub fn is_excluded ( & self , name : & str ) -> bool {
96- if self . is_included_explicitly ( name) {
97- return false ;
98- }
99-
100- if self . is_excluded_explicitly ( name) {
101- return true ;
102- }
103-
104- false
87+ #[ allow( dead_code) ]
88+ pub fn is_included ( & self , name : & str ) -> bool {
89+ !self . is_excluded ( name)
10590 }
10691
107- pub fn is_excluded_explicitly ( & self , name : & str ) -> bool {
92+ pub fn is_excluded ( & self , name : & str ) -> bool {
10893 let Some ( excluded) = & self . exclude else {
10994 return false ;
11095 } ;
11196
11297 if excluded. is_empty ( ) {
113- if let Some ( included) = & self . include {
114- return !included. contains ( name) ;
115- } else {
116- return true ;
117- }
118- }
119-
120- excluded. contains ( name)
121- }
122-
123- pub fn is_included_explicitly ( & self , name : & str ) -> bool {
124- let Some ( included) = & self . include else {
125- return false ;
126- } ;
127-
128- if included. is_empty ( ) {
129- if let Some ( excluded) = & self . exclude {
130- return !excluded. contains ( name) ;
131- } else {
132- return true ;
133- }
98+ true
99+ } else {
100+ excluded. contains ( name)
134101 }
135-
136- included. contains ( name)
137102 }
138103}
139104
@@ -205,19 +170,9 @@ pub(crate) fn config_for_variant(variant: &syn::Variant) -> Result<VariantConfig
205170
206171 let mut exclude = config. exclude . take ( ) . unwrap_or_default ( ) ;
207172
208- let opposite = config. include . as_ref ( ) ;
209- exclude. extend_idents ( macro_selection_config_for_variant ( & meta, opposite) ?. idents ) ;
173+ exclude. extend_idents ( macro_selection_config_for_variant ( & meta) ?. idents ) ;
210174
211175 config. exclude = Some ( exclude) ;
212- } else if meta. path . is_ident ( attr:: INCLUDE ) {
213- // #[enumcapsulate(include(…))]
214-
215- let mut include = config. include . take ( ) . unwrap_or_default ( ) ;
216-
217- let opposite: Option < & MacroSelectionConfig > = config. exclude . as_ref ( ) ;
218- include. extend_idents ( macro_selection_config_for_variant ( & meta, opposite) ?. idents ) ;
219-
220- config. include = Some ( include) ;
221176 } else if meta. path . is_ident ( attr:: FIELD ) {
222177 // #[enumcapsulate(field(…))]
223178 meta. parse_nested_meta ( |meta| {
@@ -311,16 +266,12 @@ pub(crate) fn macro_selection_config_for_enum(
311266
312267pub ( crate ) fn macro_selection_config_for_variant (
313268 meta : & syn:: meta:: ParseNestedMeta < ' _ > ,
314- opposite : Option < & MacroSelectionConfig > ,
315269) -> Result < MacroSelectionConfig , syn:: Error > {
316270 let idents = parse_idents_from_meta_list ( meta) ?;
317271
318272 let recognized = RECOGNIZED_VARIANT_LEVEL_MACROS ;
319273 ensure_only_recognized_ident_names ( & idents, recognized) ?;
320274
321- let conflict_list = opposite. map ( |config| config. idents ( ) ) . unwrap_or ( & [ ] ) ;
322- ensure_no_conflicting_idents ( & idents, conflict_list) ?;
323-
324275 Ok ( MacroSelectionConfig { idents } )
325276}
326277
@@ -350,32 +301,6 @@ pub(crate) fn ensure_only_recognized_ident_names(
350301 Ok ( ( ) )
351302}
352303
353- pub ( crate ) fn ensure_no_conflicting_idents (
354- idents : & [ syn:: Ident ] ,
355- conflicting : & [ syn:: Ident ] ,
356- ) -> Result < ( ) , syn:: Error > {
357- let mut error: Option < syn:: Error > = None ;
358-
359- let conflicting = idents
360- . iter ( )
361- . filter ( |& ident| conflicting. iter ( ) . any ( |conflicting| ident == conflicting) ) ;
362-
363- for ident in conflicting {
364- let ident_err = syn:: Error :: new_spanned ( ident, "conflicting macro derive" ) ;
365- if let Some ( error) = error. as_mut ( ) {
366- error. combine ( ident_err) ;
367- } else {
368- error = Some ( ident_err)
369- }
370- }
371-
372- if let Some ( err) = error {
373- return Err ( err) ;
374- }
375-
376- Ok ( ( ) )
377- }
378-
379304pub ( crate ) fn parse_idents_from_meta_list (
380305 meta : & syn:: meta:: ParseNestedMeta < ' _ > ,
381306) -> Result < Vec < syn:: Ident > , syn:: Error > {
0 commit comments