about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorMichael Sullivan <sully@msully.net>2011-08-18 16:31:23 -0700
committerMichael Sullivan <sully@msully.net>2011-08-18 16:31:23 -0700
commit6e5af8996d748fe9e75c53d9ae83c7a8cd6b317f (patch)
tree45dece09df2526b924f89db48187b3b3c3c91b8d /src/comp
parentddc2076902c7286c3766c406e17d63a1eac90098 (diff)
downloadrust-6e5af8996d748fe9e75c53d9ae83c7a8cd6b317f.tar.gz
rust-6e5af8996d748fe9e75c53d9ae83c7a8cd6b317f.zip
Get rid of equal_type_structures. Closes #514.
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/ty.rs185
1 files changed, 1 insertions, 184 deletions
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index cf46e8b2a0f..aa527ed0bfd 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -1568,191 +1568,8 @@ fn constrs_eq(cs: &[@constr], ds: &[@constr]) -> bool {
     ret true;
 }
 
-fn equal_type_structures(a: &sty, b: &sty) -> bool {
-    fn equal_mt(a: &mt, b: &mt) -> bool {
-        ret a.mut == b.mut && eq_ty(a.ty, b.ty);
-    }
-    fn equal_fn(args_a: &[arg], rty_a: &t, args_b: &[arg], rty_b: &t) ->
-       bool {
-        if !eq_ty(rty_a, rty_b) { ret false; }
-        let len = vec::len::<arg>(args_a);
-        if len != vec::len::<arg>(args_b) { ret false; }
-        let i = 0u;
-        while i < len {
-            let arg_a = args_a.(i);
-            let arg_b = args_b.(i);
-            if arg_a.mode != arg_b.mode { ret false; }
-            if !eq_ty(arg_a.ty, arg_b.ty) { ret false; }
-            i += 1u;
-        }
-        ret true;
-    }
-    fn equal_def(did_a: &ast::def_id, did_b: &ast::def_id) -> bool {
-        ret did_a.crate == did_b.crate && did_a.node == did_b.node;
-    }
-    alt a {
-      ty_nil. { alt b { ty_nil. { ret true; } _ { ret false; } } }
-      ty_bot. { alt b { ty_bot. { ret true; } _ { ret false; } } }
-      ty_bool. { alt b { ty_bool. { ret true; } _ { ret false; } } }
-      ty_int. { alt b { ty_int. { ret true; } _ { ret false; } } }
-      ty_float. { alt b { ty_float. { ret true; } _ { ret false; } } }
-      ty_uint. { alt b { ty_uint. { ret true; } _ { ret false; } } }
-      ty_machine(tm_a) {
-        alt b {
-          ty_machine(tm_b) {
-            ret hash_type_structure(a) == hash_type_structure(b);
-          }
-          _ { ret false; }
-        }
-      }
-      ty_char. { alt b { ty_char. { ret true; } _ { ret false; } } }
-      ty_str. { alt b { ty_str. { ret true; } _ { ret false; } } }
-      ty_istr. { alt b { ty_istr. { ret true; } _ { ret false; } } }
-      ty_tag(id_a, tys_a) {
-        alt b {
-          ty_tag(id_b, tys_b) {
-            if !equal_def(id_a, id_b) { ret false; }
-            let len = vec::len::<t>(tys_a);
-            if len != vec::len::<t>(tys_b) { ret false; }
-            let i = 0u;
-            while i < len {
-                if !eq_ty(tys_a.(i), tys_b.(i)) { ret false; }
-                i += 1u;
-            }
-            ret true;
-          }
-          _ { ret false; }
-        }
-      }
-      ty_box(mt_a) {
-        alt b { ty_box(mt_b) { ret equal_mt(mt_a, mt_b); } _ { ret false; } }
-      }
-      ty_vec(mt_a) {
-        alt b { ty_vec(mt_b) { ret equal_mt(mt_a, mt_b); } _ { ret false; } }
-      }
-      ty_ptr(mt_a) {
-        alt b { ty_ptr(mt_b) { ret equal_mt(mt_a, mt_b); } _ { ret false; } }
-      }
-      ty_rec(flds_a) {
-        alt b {
-          ty_rec(flds_b) {
-            let len = vec::len::<field>(flds_a);
-            if len != vec::len::<field>(flds_b) { ret false; }
-            let i = 0u;
-            while i < len {
-                let fld_a = flds_a.(i);
-                let fld_b = flds_b.(i);
-                if !str::eq(fld_a.ident, fld_b.ident) ||
-                       !equal_mt(fld_a.mt, fld_b.mt) {
-                    ret false;
-                }
-                i += 1u;
-            }
-            ret true;
-          }
-          _ { ret false; }
-        }
-      }
-      ty_tup(ts_a) {
-        alt (b) {
-          ty_tup(ts_b) {
-            let len = vec::len(ts_a);
-            if len != vec::len(ts_b) { ret false; }
-            let i = 0u;
-            while i < len {
-                if !eq_ty(ts_a.(i), ts_b.(i)) { ret false; }
-                i += 1u;
-            }
-            ret true;
-          }
-          _ { ret false; }
-        }
-      }
-
-      ty_fn(p_a, args_a, rty_a, cf_a, constrs_a) {
-        alt b {
-          ty_fn(p_b, args_b, rty_b, cf_b, constrs_b) {
-            ret p_a == p_b && cf_a == cf_b && constrs_eq(constrs_a, constrs_b)
-                    && equal_fn(args_a, rty_a, args_b, rty_b);
-          }
-          _ { ret false; }
-        }
-      }
-      ty_native_fn(abi_a, args_a, rty_a) {
-        alt b {
-          ty_native_fn(abi_b, args_b, rty_b) {
-            ret abi_a == abi_b && equal_fn(args_a, rty_a, args_b, rty_b);
-          }
-          _ { ret false; }
-        }
-      }
-      ty_obj(methods_a) {
-        alt b {
-          ty_obj(methods_b) {
-            let len = vec::len::<method>(methods_a);
-            if len != vec::len::<method>(methods_b) { ret false; }
-            let i = 0u;
-            while i < len {
-                let m_a = methods_a.(i);
-                let m_b = methods_b.(i);
-                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) {
-                    ret false;
-                }
-                i += 1u;
-            }
-            ret true;
-          }
-          _ { ret false; }
-        }
-      }
-      ty_res(id_a, inner_a, tps_a) {
-        alt b {
-          ty_res(id_b, inner_b, tps_b) {
-            if !equal_def(id_a, id_b) || !eq_ty(inner_a, inner_b) {
-                ret false;
-            }
-            let i = 0u;
-            for tp_a: t in tps_a {
-                if !eq_ty(tp_a, tps_b.(i)) { ret false; }
-                i += 1u;
-            }
-            ret true;
-          }
-          _ { ret false; }
-        }
-      }
-      ty_var(v_a) {
-        alt b { ty_var(v_b) { ret v_a == v_b; } _ { ret false; } }
-      }
-      ty_param(pid_a,k_a) {
-        alt b { ty_param(pid_b,k_b) { ret pid_a == pid_b && k_a == k_b; }
-               _ { ret false; } }
-      }
-      ty_type. { alt b { ty_type. { ret true; } _ { ret false; } } }
-      ty_native(a_id) {
-        alt b {
-          ty_native(b_id) {
-            ret a_id.crate == b_id.crate && a_id.node == b_id.node;
-          }
-          _ { ret false; }
-        }
-      }
-      ty_uniq(t_a) {
-        alt b {
-          ty_uniq(t_b) { ret t_a == t_b; }
-          _ { ret false; }
-        }
-      }
-    }
-}
-
-
 // An expensive type equality function. This function is private to this
 // module.
-//
-// FIXME: Use structural comparison, but this loops forever and segfaults.
 fn eq_raw_ty(a: &@raw_t, b: &@raw_t) -> bool {
     // Check hashes (fast path).
 
@@ -1770,7 +1587,7 @@ fn eq_raw_ty(a: &@raw_t, b: &@raw_t) -> bool {
     }
     // Check structures.
 
-    ret equal_type_structures(a.struct, b.struct);
+    ret a.struct == b.struct;
 }