@@ -1442,6 +1442,8 @@ fn decr_refcnt_and_if_zero(@block_ctxt cx,
1442
1442
ret res( next_cx, phi) ;
1443
1443
}
1444
1444
1445
+ // Tag information
1446
+
1445
1447
fn type_of_variant( @crate_ctxt cx, & ast. variant v) -> TypeRef {
1446
1448
let vec[ TypeRef ] lltys = vec( ) ;
1447
1449
alt ( ty. ann_to_type( v. ann) . struct ) {
@@ -1455,6 +1457,17 @@ fn type_of_variant(@crate_ctxt cx, &ast.variant v) -> TypeRef {
1455
1457
ret T_struct ( lltys) ;
1456
1458
}
1457
1459
1460
+ // Returns the number of variants in a tag.
1461
+ fn tag_variant_count( @crate_ctxt cx, ast. def_id id) -> uint {
1462
+ check ( cx. items. contains_key( id) ) ;
1463
+ alt ( cx. items. get( id) . node) {
1464
+ case ( ast. item_tag( _, ?variants, _, _) ) {
1465
+ ret _vec. len[ ast. variant] ( variants) ;
1466
+ }
1467
+ }
1468
+ fail; // not reached
1469
+ }
1470
+
1458
1471
type val_and_ty_fn = fn ( @block_ctxt cx, ValueRef v, @ty. t t) -> result;
1459
1472
1460
1473
// Iterates through the elements of a structural type.
@@ -1506,7 +1519,7 @@ fn iter_structural_ty(@block_ctxt cx,
1506
1519
case ( ty. ty_tag( ?tid, ?tps) ) {
1507
1520
check ( cx. fcx. ccx. tags. contains_key( tid) ) ;
1508
1521
auto info = cx. fcx. ccx. tags. get( tid) ;
1509
- auto n_variants = _vec . len [ tup ( ast . def_id , arity ) ] ( info . variants ) ;
1522
+ auto n_variants = tag_variant_count ( cx . fcx . ccx , tid ) ;
1510
1523
1511
1524
// Look up the tag in the typechecked AST.
1512
1525
check ( cx. fcx. ccx. items. contains_key( tid) ) ;
0 commit comments