Skip to content

Commit eefeb66

Browse files
committed
Fix parsing of enum-level #[enumcapsulate(exclude(From, TryInto))] helper attribute
1 parent 082405b commit eefeb66

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

macros/src/config.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,13 @@ pub(crate) fn encapsulate_config_for_enum(
148148

149149
let mut exclude = config.exclude.take().unwrap_or_default();
150150

151-
if exclude.is_empty() {
151+
let idents = macro_selection_config_for_enum(&meta)?.idents;
152+
153+
if idents.is_empty() {
152154
return Err(meta.error("expected list"));
153155
}
154156

155-
exclude.extend_idents(macro_selection_config_for_enum(&meta)?.idents);
157+
exclude.extend_idents(idents);
156158

157159
config.exclude = Some(exclude);
158160
} else {
@@ -172,7 +174,12 @@ pub(crate) fn config_for_enum(enum_item: &syn::ItemEnum) -> Result<EnumConfig, s
172174
if meta.path.is_ident(attr::EXCLUDE) {
173175
// #[enumcapsulate(exclude(…))]
174176

175-
// Ignored.
177+
meta.parse_nested_meta(|_meta| {
178+
// Here we're not interested in any of the existing
179+
// sub-attributes, but we need to parse the list anyway.
180+
181+
Ok(())
182+
})?;
176183
} else {
177184
return Err(meta.error("unrecognized attribute"));
178185
}
@@ -378,6 +385,7 @@ pub(crate) fn parse_idents_from_meta_list(
378385
if lookahead.peek(syn::token::Paren) {
379386
let content;
380387
syn::parenthesized!(content in meta.input);
388+
381389
let punctuated: Punctuated<syn::Ident, syn::Token![,]> =
382390
content.parse_terminated(syn::Ident::parse, syn::Token![,])?;
383391

0 commit comments

Comments
 (0)