From fe9986759010cff5833290284a4b26d12e3a98bd Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 23 Oct 2015 10:49:01 -0700 Subject: [PATCH] num-macros: port from ast::VariantKind to ast::VariantData --- num-macros/src/lib.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/num-macros/src/lib.rs b/num-macros/src/lib.rs index e1c1243..4cbcece 100644 --- a/num-macros/src/lib.rs +++ b/num-macros/src/lib.rs @@ -132,15 +132,8 @@ fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure let mut arms = Vec::new(); for variant in &enum_def.variants { - match variant.node.kind { - ast::TupleVariantKind(ref args) => { - if !args.is_empty() { - cx.span_err(trait_span, - "`FromPrimitive` cannot be derived for \ - enum variants with arguments"); - return cx.expr_fail(trait_span, - InternedString::new("")); - } + match *variant.node.data { + ast::VariantData::Unit(..) => { let span = variant.span; // expr for `$n == $variant as $name` @@ -163,7 +156,14 @@ fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure arms.push(arm); } - ast::StructVariantKind(_) => { + ast::VariantData::Tuple(..) => { + cx.span_err(trait_span, + "`FromPrimitive` cannot be derived for \ + enum variants with arguments"); + return cx.expr_fail(trait_span, + InternedString::new("")); + } + ast::VariantData::Struct(..) => { cx.span_err(trait_span, "`FromPrimitive` cannot be derived for enums \ with struct variants");