num-macros: port from ast::VariantKind to ast::VariantData

This commit is contained in:
Josh Stone 2015-10-23 10:49:01 -07:00
parent 9e5a209dcd
commit fe99867590
1 changed files with 10 additions and 10 deletions

View File

@ -132,15 +132,8 @@ fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure
let mut arms = Vec::new(); let mut arms = Vec::new();
for variant in &enum_def.variants { for variant in &enum_def.variants {
match variant.node.kind { match *variant.node.data {
ast::TupleVariantKind(ref args) => { ast::VariantData::Unit(..) => {
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(""));
}
let span = variant.span; let span = variant.span;
// expr for `$n == $variant as $name` // 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); 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, cx.span_err(trait_span,
"`FromPrimitive` cannot be derived for enums \ "`FromPrimitive` cannot be derived for enums \
with struct variants"); with struct variants");