Skip to content

Commit 4585d20

Browse files
committed
Fix failing tests.
1 parent 7a4e224 commit 4585d20

1 file changed

Lines changed: 42 additions & 49 deletions

File tree

src/lib.rs

Lines changed: 42 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -202,62 +202,55 @@ fn enum_variant_type_impl(ast: DeriveInput) -> proc_macro2::TokenStream {
202202
.unwrap_or_else(|e| panic!("Failed to parse repr attribute. Error: {}", e));
203203
}
204204
} else if attr.path().is_ident("evt") {
205-
if let Meta::List(list) = &attr.meta {
206-
list.parse_nested_meta(|parse_nested_meta| {
207-
if parse_nested_meta.path.is_ident("module") {
208-
// `#[evt(module = \"some_module_name\")]`
209-
let module_name: LitStr = parse_nested_meta
210-
.value()
211-
.and_then(|value| value.parse())
212-
.unwrap_or_else(|e| {
213-
panic!(
214-
"Expected `evt` attribute argument in the form: \
205+
attr.parse_nested_meta(|nested_meta| {
206+
if nested_meta.path.is_ident("module") {
207+
// `#[evt(module = \"some_module_name\")]`
208+
let module_name: LitStr = nested_meta
209+
.value()
210+
.and_then(|value| value.parse())
211+
.unwrap_or_else(|e| {
212+
panic!(
213+
"Expected `evt` attribute argument in the form: \
215214
`#[evt(module = \"some_module_name\")]`. Error: {}",
216-
e
217-
)
218-
});
219-
220-
wrap_in_module = Some(Ident::new(&module_name.value(), Span::call_site()));
221-
return Ok(());
222-
}
223-
// `#[evt(derive(Clone, Debug))]`
224-
if parse_nested_meta.path.is_ident("derive") {
225-
let mut items = Vec::new();
226-
list.parse_nested_meta(|parse_nested_meta| {
227-
items.push(parse_nested_meta.path);
228-
Ok(())
229-
})?;
230-
231-
derive_for_all_variants = Some(parse_quote! {
232-
#[derive( #(#items),* )]
215+
e
216+
)
233217
});
234-
return Ok(());
235-
}
236218

237-
// `#[evt(implement_marker_traits(MarkerTrait1, MarkerTrait2))]`
238-
if parse_nested_meta.path.is_ident("implement_marker_traits") {
239-
list.parse_nested_meta(|parse_nested_meta| {
240-
marker_trait_paths.push(parse_nested_meta.path);
241-
Ok(())
242-
})?;
219+
wrap_in_module = Some(Ident::new(&module_name.value(), Span::call_site()));
220+
return Ok(());
221+
}
222+
// `#[evt(derive(Clone, Debug))]`
223+
if nested_meta.path.is_ident("derive") {
224+
let mut items = Vec::new();
225+
nested_meta.parse_nested_meta(|parse_nested_meta| {
226+
items.push(parse_nested_meta.path);
227+
Ok(())
228+
})?;
229+
230+
derive_for_all_variants = Some(parse_quote! {
231+
#[derive( #(#items),* )]
232+
});
233+
return Ok(());
234+
}
243235

244-
return Ok(());
245-
}
236+
// `#[evt(implement_marker_traits(MarkerTrait1, MarkerTrait2))]`
237+
if nested_meta.path.is_ident("implement_marker_traits") {
238+
nested_meta.parse_nested_meta(|parse_nested_meta| {
239+
marker_trait_paths.push(parse_nested_meta.path);
240+
Ok(())
241+
})?;
242+
243+
return Ok(());
244+
}
246245

247-
panic!(
248-
"Unexpected usage of `evt` attribute, please see examples at:\n\
249-
<https://docs.rs/enum_variant_type/>"
250-
)
251-
})
252-
.unwrap_or_else(|e| {
253-
panic!("Failed to process evt attribute. Error: {}", e);
254-
});
255-
} else {
256246
panic!(
257-
"Unexpected usage of `evt` attribute, please see examples at:\
258-
\n<https://docs.rs/enum_variant_type/>"
247+
"Unexpected usage of `evt` attribute, please see examples at:\n\
248+
<https://docs.rs/enum_variant_type/>"
259249
)
260-
}
250+
})
251+
.unwrap_or_else(|e| {
252+
panic!("Failed to process evt attribute. Error: {}", e);
253+
});
261254
}
262255
}
263256

0 commit comments

Comments
 (0)