about summary refs log tree commit diff
path: root/src/rustc
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2012-06-01 14:46:37 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2012-06-01 20:40:34 -0700
commitbc5cb4deb34cc767af20eedc55fed5f528680938 (patch)
treec8b80382e95de03fc6432f9d7359c7d542e4d2c9 /src/rustc
parent1e801baa84af732651e0210f181ca3572a62e459 (diff)
Change type_needs_drop to say that any class w/ a dtor needs a drop
This was preventing dtors from running for class types that didn't
have pointer fields.
Diffstat (limited to 'src/rustc')
-rw-r--r--src/rustc/middle/ty.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs
index 07f6e7749ec..385159bbfbc 100644
--- a/src/rustc/middle/ty.rs
+++ b/src/rustc/middle/ty.rs
@@ -1174,10 +1174,13 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
         accum
       }
       ty_class(did, substs) {
-        for vec::each(ty::class_items_as_fields(cx, did, substs)) {|f|
-            if type_needs_drop(cx, f.mt.ty) { accum = true; }
-        }
-        accum
+         // Any class with a dtor needs a drop
+         option::is_some(ty_dtor(cx, did)) || {
+           for vec::each(ty::class_items_as_fields(cx, did, substs)) {|f|
+             if type_needs_drop(cx, f.mt.ty) { accum = true; }
+           }
+           accum
+         }
       }
 
       ty_tup(elts) {