+ fn drop(&mut self, ptr: Pointer, ty: ty::Ty<'tcx>) -> EvalResult<()> {
+ if !self.type_needs_drop(ty) {
+ self.log(1, || print!("no need to drop {:?}", ty));
+ return Ok(());
+ }
+ self.log(1, || print!("need to drop {:?}", ty));
+
+ match ty.sty {
+ ty::TyBox(contents_ty) => {
+ let contents_ptr = try!(self.memory.read_ptr(ptr));
+ try!(self.drop(contents_ptr, contents_ty));
+ self.log(1, || print!("deallocating box"));
+ try!(self.memory.deallocate(contents_ptr));
+ }
+
+ // TODO(tsion): Implement drop for other relevant types (e.g. aggregates).
+ _ => {}
+ }
+
+ Ok(())
+ }
+