Remove filling drop to prep for elaborated drops.
This commit is contained in:
parent
339e703e0b
commit
756d73b3ca
4 changed files with 8 additions and 38 deletions
|
@ -820,9 +820,6 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||
fn move_(&mut self, src: Pointer, dest: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx, ()> {
|
||||
let size = self.type_size(ty);
|
||||
self.memory.copy(src, dest, size)?;
|
||||
if self.type_needs_drop(ty) {
|
||||
self.memory.drop_fill(src, size)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use rustc::ty::layout::Layout;
|
|||
use rustc::ty::subst::{self, Substs};
|
||||
use rustc::ty::{self, Ty, TyCtxt, BareFnTy};
|
||||
use std::rc::Rc;
|
||||
use std::{iter, mem};
|
||||
use std::iter;
|
||||
use syntax::{ast, attr};
|
||||
use syntax::codemap::{DUMMY_SP, Span};
|
||||
|
||||
|
@ -303,11 +303,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||
self.memory.write_uint(dest, discr_val, 8)?;
|
||||
}
|
||||
|
||||
"forget" => {
|
||||
let arg_ty = *substs.types.get(subst::FnSpace, 0);
|
||||
let arg_size = self.type_size(arg_ty);
|
||||
self.memory.drop_fill(args_ptrs[0], arg_size)?;
|
||||
}
|
||||
"forget" => {}
|
||||
|
||||
"init" => self.memory.write_repeat(dest, 0, dest_layout.size(&self.tcx.data_layout).bytes() as usize)?,
|
||||
|
||||
|
@ -549,35 +545,17 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||
// TODO(solson): Call user-defined Drop::drop impls.
|
||||
|
||||
match ty.sty {
|
||||
ty::TyBox(contents_ty) => {
|
||||
match self.memory.read_ptr(ptr) {
|
||||
Ok(contents_ptr) => {
|
||||
self.drop(contents_ptr, contents_ty)?;
|
||||
trace!("-deallocating box");
|
||||
self.memory.deallocate(contents_ptr)?;
|
||||
}
|
||||
Err(EvalError::ReadBytesAsPointer) => {
|
||||
let size = self.memory.pointer_size();
|
||||
let possible_drop_fill = self.memory.read_bytes(ptr, size)?;
|
||||
if possible_drop_fill.iter().all(|&b| b == mem::POST_DROP_U8) {
|
||||
return Ok(());
|
||||
} else {
|
||||
return Err(EvalError::ReadBytesAsPointer);
|
||||
}
|
||||
}
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
ty::TyBox(_contents_ty) => {
|
||||
let contents_ptr = self.memory.read_ptr(ptr)?;
|
||||
// self.drop(contents_ptr, contents_ty)?;
|
||||
trace!("-deallocating box");
|
||||
self.memory.deallocate(contents_ptr)?;
|
||||
}
|
||||
|
||||
// TODO(solson): Implement drop for other relevant types (e.g. aggregates).
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// Filling drop.
|
||||
// FIXME(solson): Trait objects (with no static size) probably get filled, too.
|
||||
let size = self.type_size(ty);
|
||||
self.memory.drop_fill(ptr, size)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
btree_range,
|
||||
collections,
|
||||
collections_bound,
|
||||
filling_drop,
|
||||
question_mark,
|
||||
rustc_private,
|
||||
pub_restricted,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian, BigEndian, self};
|
||||
use std::collections::Bound::{Included, Excluded};
|
||||
use std::collections::{btree_map, BTreeMap, HashMap, HashSet, VecDeque};
|
||||
use std::{fmt, iter, mem, ptr};
|
||||
use std::{fmt, iter, ptr};
|
||||
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::ty::BareFnTy;
|
||||
|
@ -340,10 +340,6 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn drop_fill(&mut self, ptr: Pointer, size: usize) -> EvalResult<'tcx, ()> {
|
||||
self.write_repeat(ptr, mem::POST_DROP_U8, size)
|
||||
}
|
||||
|
||||
pub fn read_ptr(&self, ptr: Pointer) -> EvalResult<'tcx, Pointer> {
|
||||
let size = self.pointer_size();
|
||||
self.check_defined(ptr, size)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue