diff options
| author | Brian Anderson <[email protected]> | 2011-03-06 13:56:38 -0500 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-03-06 15:13:35 -0800 |
| commit | d39da6f97819becd9ea41c194b5f0daa178814fe (patch) | |
| tree | 71f4f00e321803d1cf9ab61de31a8725d6befeb6 /src/comp/front | |
| parent | Flatten conditionals in rustc.rs. Remove FIXME (diff) | |
| download | rust-d39da6f97819becd9ea41c194b5f0daa178814fe.tar.xz rust-d39da6f97819becd9ea41c194b5f0daa178814fe.zip | |
Remove typestate workarounds
Diffstat (limited to 'src/comp/front')
| -rw-r--r-- | src/comp/front/extfmt.rs | 17 | ||||
| -rw-r--r-- | src/comp/front/parser.rs | 18 |
2 files changed, 10 insertions, 25 deletions
diff --git a/src/comp/front/extfmt.rs b/src/comp/front/extfmt.rs index 7201a17c..255614d0 100644 --- a/src/comp/front/extfmt.rs +++ b/src/comp/front/extfmt.rs @@ -244,9 +244,7 @@ fn parse_count(str s, uint i, uint lim) -> tup(count, uint) { ret tup(count_implied, i); } - // FIXME: These inner functions are just to avoid a rustboot - // "Unsatisfied precondition constraint" bug with alts nested in ifs - fn parse_star_count(str s, uint i, uint lim) -> tup(count, uint) { + if (s.(i) == ('*' as u8)) { auto param = parse_parameter(s, i + 1u, lim); auto j = param._1; alt (param._0) { @@ -257,9 +255,7 @@ fn parse_count(str s, uint i, uint lim) -> tup(count, uint) { ret tup(count_is_param(n), j); } } - } - - fn parse_count_(str s, uint i, uint lim) -> tup(count, uint) { + } else { auto num = peek_num(s, i, lim); alt (num) { case (none[tup(uint, uint)]) { @@ -270,12 +266,6 @@ fn parse_count(str s, uint i, uint lim) -> tup(count, uint) { } } } - - if (s.(i) == ('*' as u8)) { - ret parse_star_count(s, i, lim); - } else { - ret parse_count_(s, i, lim); - } } fn parse_precision(str s, uint i, uint lim) -> tup(count, uint) { @@ -318,9 +308,6 @@ fn parse_type(str s, uint i, uint lim) -> tup(ty, uint) { } else if (_str.eq(tstr, "t")) { t = ty_bits; } else { - // FIXME: This is a hack to avoid 'unsatisfied precondition - // constraint' on uninitialized variable t below - t = ty_bool; log "unknown type in conversion"; fail; } diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 934764e6..8665a425 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -1365,7 +1365,7 @@ impure fn parse_initializer(parser p) -> option.t[@ast.expr] { impure fn parse_pat(parser p) -> @ast.pat { auto lo = p.get_span(); auto hi = lo; - auto pat = ast.pat_wild(ast.ann_none); // FIXME: typestate bug + auto pat; alt (p.peek()) { case (token.UNDERSCORE) { @@ -1541,31 +1541,28 @@ fn index_block(vec[@ast.stmt] stmts, option.t[@ast.expr] expr) -> ast.block_ { auto index = new_str_hash[uint](); auto u = 0u; for (@ast.stmt s in stmts) { - // FIXME: typestate bug requires we do this up top, not - // down below loop. Sigh. - u += 1u; alt (s.node) { case (ast.stmt_decl(?d)) { alt (d.node) { case (ast.decl_local(?loc)) { - index.insert(loc.ident, u-1u); + index.insert(loc.ident, u); } case (ast.decl_item(?it)) { alt (it.node) { case (ast.item_fn(?i, _, _, _, _)) { - index.insert(i, u-1u); + index.insert(i, u); } case (ast.item_mod(?i, _, _)) { - index.insert(i, u-1u); + index.insert(i, u); } case (ast.item_ty(?i, _, _, _, _)) { - index.insert(i, u-1u); + index.insert(i, u); } case (ast.item_tag(?i, _, _, _)) { - index.insert(i, u-1u); + index.insert(i, u); } case (ast.item_obj(?i, _, _, _, _)) { - index.insert(i, u-1u); + index.insert(i, u); } } } @@ -1573,6 +1570,7 @@ fn index_block(vec[@ast.stmt] stmts, option.t[@ast.expr] expr) -> ast.block_ { } case (_) { /* fall through */ } } + u += 1u; } ret rec(stmts=stmts, expr=expr, index=index); } |