diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp index b0f6f1f77a4..57fd23cb633 100644 --- a/src/rt/rust_shape.cpp +++ b/src/rt/rust_shape.cpp @@ -356,7 +356,7 @@ cmp::walk_struct2(const uint8_t *end_sp) { void cmp::walk_res2(const rust_fn *dtor, const uint8_t *end_sp) { - abort(); // TODO + return cmp_two_pointers(); } void diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index d7e7020f20d..4ef40f4f924 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -334,7 +334,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] { let mut s = if option::is_some(m_dtor_did) { [shape_res] } - else { [shape_struct] }; + else { [shape_struct] }, sub = []; option::iter(m_dtor_did) {|dtor_did| let ri = @{did: dtor_did, parent_id: some(did), tps: tps}; let id = interner::intern(ccx.shape_cx.resources, ri); @@ -345,8 +345,9 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] { add_u16(s, 0_u16); }; for ty::class_items_as_mutable_fields(ccx.tcx, did, substs).each {|f| - add_substr(s, shape_of(ccx, f.mt.ty)); + sub += shape_of(ccx, f.mt.ty); } + add_substr(s, sub); s } ty::ty_rptr(_, mt) { diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs index 047e0d41e23..59c9c2bee25 100644 --- a/src/test/run-pass/binops.rs +++ b/src/test/run-pass/binops.rs @@ -60,14 +60,11 @@ fn test_box() { } fn test_port() { - // FIXME: Re-enable this once we can compare resources. (#2601) - /* let p1 = comm::port::(); let p2 = comm::port::(); assert (p1 == p1); assert (p1 != p2); - */ } fn test_chan() { @@ -98,7 +95,7 @@ fn test_ptr() unsafe { fn test_fn() { fn f() { } fn g() { } - fn h(i: int) { } + fn h(_i: int) { } let f1 = f; let f2 = f; let g1 = g; @@ -128,6 +125,28 @@ fn test_native_fn() { assert test::unsupervise == test::unsupervise; } +class p { + let mut x: int; + let mut y: int; + new(x: int, y: int) { self.x = x; self.y = y; } +} + +fn test_class() { + let q = p(1, 2); + let r = p(1, 2); + + unsafe { + #error("q = %x, r = %x", + (unsafe::reinterpret_cast::<*p, uint>(ptr::addr_of(q))), + (unsafe::reinterpret_cast::<*p, uint>(ptr::addr_of(r)))); + } + assert(q == r); + r.y = 17; + assert(r.y != q.y); + assert(r.y == 17); + assert(q != r); +} + fn main() { test_nil(); test_bool(); @@ -138,4 +157,5 @@ fn main() { test_ptr(); test_fn(); test_native_fn(); + test_class(); }