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/middle/ty.rs | |
| 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/middle/ty.rs')
| -rw-r--r-- | src/comp/middle/ty.rs | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 0b6ef53b..3f209d3c 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1018,32 +1018,6 @@ fn unify(@ty.t expected, @ty.t actual, &unify_handler handler) ret ures_err(terr_meth_count, expected, actual); } - // FIXME: work around buggy typestate logic for 'alt', sigh. - fn is_ok(&unify_result r) -> bool { - alt (r) { - case (ures_ok(?tfn)) { - ret true; - } - case (_) {} - } - ret false; - } - - fn append_if_ok(&method e_meth, - &unify_result r, &mutable vec[method] result_meths) { - alt (r) { - case (ures_ok(?tfn)) { - alt (tfn.struct) { - case (ty_fn(?proto, ?ins, ?out)) { - result_meths += vec(rec(inputs = ins, - output = out - with e_meth)); - } - } - } - } - } - while (i < expected_len) { auto e_meth = expected_meths.(i); auto a_meth = actual_meths.(i); @@ -1056,10 +1030,20 @@ fn unify(@ty.t expected, @ty.t actual, &unify_handler handler) expected, actual, handler, e_meth.inputs, e_meth.output, a_meth.inputs, a_meth.output); - if (!is_ok(r)) { - ret r; + alt (r) { + case (ures_ok(?tfn)) { + alt (tfn.struct) { + case (ty_fn(?proto, ?ins, ?out)) { + result_meths += vec(rec(inputs = ins, + output = out + with e_meth)); + } + } + } + case (_) { + ret r; + } } - append_if_ok(e_meth, r, result_meths); i += 1u; } auto t = plain_ty(ty_obj(result_meths)); |