]> git.lizzy.rs Git - rust.git/commitdiff
change function and place in expr.rs
authorMahmut Bulut <mahmutbulut0@gmail.com>
Wed, 31 Oct 2012 22:49:37 +0000 (00:49 +0200)
committerMahmut Bulut <mahmutbulut0@gmail.com>
Wed, 31 Oct 2012 22:49:37 +0000 (00:49 +0200)
src/rustc/middle/trans/datum.rs
src/rustc/middle/trans/expr.rs

index 4a2c82cc7266f7b4a49bb923a4162ea8eb822231..5e11cdd479436e6f02ad5f218d482790e45b7e60 100644 (file)
@@ -542,25 +542,6 @@ fn drop_val(bcx: block) -> block {
         };
     }
 
-    fn dropnzero_val(bcx: block) -> block {
-        if !ty::type_needs_drop(bcx.tcx(), self.ty) {
-            return bcx;
-        }
-
-        return match self.mode {
-            ByRef => {
-                glue::drop_ty(bcx, self.val, self.ty);
-                zero_mem(bcx, self.val, self.ty);
-                return bcx;
-            }
-            ByValue => {
-                glue::drop_ty_immediate(bcx, self.val, self.ty);
-                zero_mem(bcx, self.val, self.ty);
-                return bcx;
-            }
-        };
-    }
-
     fn box_body(bcx: block) -> Datum {
         /*!
          *
index 9e1451a3fcd9096d1065fd67ca25ac9bdaef701f..06c2421a452d7720210c139e20af07d4140a6ed2 100644 (file)
@@ -159,6 +159,12 @@ impl Dest : cmp::Eq {
     pure fn ne(other: &Dest) -> bool { !self.eq(other) }
 }
 
+fn drop_and_cancel_clean(dat: Datum, bcx: block) -> block {
+    let bcx = dat.drop_val(bcx);
+    dat.cancel_clean(bcx);
+    return bcx;
+}
+
 fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock {
     debug!("trans_to_datum(expr=%s)", bcx.expr_to_str(expr));
 
@@ -573,7 +579,7 @@ fn ast_proto_to_proto_simple(ast_proto: ast::proto)
             if bcx.expr_is_lval(a) {
                 let datum = unpack_datum!(bcx, trans_to_datum(bcx, a));
                 return match dest {
-                    Ignore => datum.dropnzero_val(bcx),
+                    Ignore => drop_and_cancel_clean(datum, bcx),
                     SaveIn(addr) => datum.move_to(bcx, INIT, addr)
                 };
             } else {