From bc5cb4deb34cc767af20eedc55fed5f528680938 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Fri, 1 Jun 2012 14:46:37 -0700 Subject: [PATCH] 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. --- src/rustc/middle/ty.rs | 11 +++++++---- 1 file 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) {