diff options
| author | Patrick Walton <[email protected]> | 2011-05-11 16:18:02 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-05-11 16:18:02 -0700 |
| commit | da09a0320ef5120b082c82148a0bb72ee97ae551 (patch) | |
| tree | 1f1bfdc00bc7e1deae8fce22cd44f88d25067065 /src/comp/middle | |
| parent | rustc: Remove magic numbers; they aren't a win (diff) | |
| download | rust-da09a0320ef5120b082c82148a0bb72ee97ae551.tar.xz rust-da09a0320ef5120b082c82148a0bb72ee97ae551.zip | |
rustc: Remove a few kludges intended to work around rustboot's lack of structural comparison from equal_type_structures()
Diffstat (limited to 'src/comp/middle')
| -rw-r--r-- | src/comp/middle/ty.rs | 78 |
1 files changed, 4 insertions, 74 deletions
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 838ee980..3cd081f6 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1160,78 +1160,8 @@ fn hash_ty(&t typ) -> uint { ret typ.hash; } // Type equality. This function is private to this module (and slow); external // users should use `eq_ty()` instead. fn equal_type_structures(&sty a, &sty b) -> bool { - - fn equal_proto(ast.proto a, ast.proto b) -> bool { - alt (a) { - case (ast.proto_iter) { - alt (b) { - case (ast.proto_iter) { ret true; } - case (_) { ret false; } - } - } - case (ast.proto_fn) { - alt (b) { - case (ast.proto_fn) { ret true; } - case (_) { ret false; } - } - } - } - } - - fn equal_abi(ast.native_abi a, ast.native_abi b) -> bool { - alt (a) { - case (ast.native_abi_rust) { - alt (b) { - case (ast.native_abi_rust) { ret true; } - case (_) { ret false; } - } - } - case (ast.native_abi_rust_intrinsic) { - alt (b) { - case (ast.native_abi_rust_intrinsic) { ret true; } - case (_) { ret false; } - } - } - case (ast.native_abi_cdecl) { - alt (b) { - case (ast.native_abi_cdecl) { ret true; } - case (_) { ret false; } - } - } - case (ast.native_abi_llvm) { - alt (b) { - case (ast.native_abi_llvm) { ret true; } - case (_) { ret false; } - } - } - } - } - - fn equal_mut(ast.mutability a, ast.mutability b) -> bool { - alt (a) { - case (ast.mut) { - alt (b) { - case (ast.mut) { ret true; } - case (_) { ret false; } - } - } - case (ast.imm) { - alt (b) { - case (ast.imm) { ret true; } - case (_) { ret false; } - } - } - case (ast.maybe_mut) { - alt (b) { - case (ast.maybe_mut) { ret true; } - case (_) { ret false; } - } - } - } - } - fn equal_mt(&mt a, &mt b) -> bool { - ret equal_mut(a.mut, b.mut) && eq_ty(a.ty, b.ty); + ret a.mut == b.mut && eq_ty(a.ty, b.ty); } fn equal_fn(&vec[arg] args_a, &t rty_a, @@ -1390,7 +1320,7 @@ fn equal_type_structures(&sty a, &sty b) -> bool { case (ty_fn(?p_a, ?args_a, ?rty_a)) { alt (b) { case (ty_fn(?p_b, ?args_b, ?rty_b)) { - ret equal_proto(p_a, p_b) && + ret p_a == p_b && equal_fn(args_a, rty_a, args_b, rty_b); } case (_) { ret false; } @@ -1399,7 +1329,7 @@ fn equal_type_structures(&sty a, &sty b) -> bool { case (ty_native_fn(?abi_a, ?args_a, ?rty_a)) { alt (b) { case (ty_native_fn(?abi_b, ?args_b, ?rty_b)) { - ret equal_abi(abi_a, abi_b) && + ret abi_a == abi_b && equal_fn(args_a, rty_a, args_b, rty_b); } case (_) { ret false; } @@ -1413,7 +1343,7 @@ fn equal_type_structures(&sty a, &sty b) -> bool { auto i = 0u; while (i < len) { auto m_a = methods_a.(i); auto m_b = methods_b.(i); - if (!equal_proto(m_a.proto, m_b.proto) || + if (m_a.proto != m_b.proto || !Str.eq(m_a.ident, m_b.ident) || !equal_fn(m_a.inputs, m_a.output, m_b.inputs, m_b.output)) { |