1
Fork 0

Support explicit discriminant numbers on tag variants.

Addresses issue #1393.

For now disallow disr. values unless all variants use nullary
contractors (i.e. "enum-like").

Disr. values are now encoded in the crate metadata, but only when it
will differ from the inferred value based on the order.
This commit is contained in:
Kevin Atkinson 2012-01-10 14:50:40 -07:00 committed by Graydon Hoare
parent d0fe6723fc
commit 08abf8d37f
12 changed files with 167 additions and 30 deletions

View file

@ -469,7 +469,9 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
ret {ty: fld.fold_ty(va.ty), id: va.id};
}
let fold_variant_arg = bind fold_variant_arg_(_, fld);
ret {name: v.name, args: vec::map(v.args, fold_variant_arg), id: v.id};
ret {name: v.name, args: vec::map(v.args, fold_variant_arg), id: v.id,
disr_val: v.disr_val, disr_expr: v.disr_expr
/* FIXME: is this right (copying disr_val and disr_expr) */};
}
fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident { ret i; }