Merge branch 'master' into mir-validate

This commit is contained in:
Ralf Jung 2017-08-23 18:09:13 +02:00 committed by GitHub
commit ae10b23a7c
3 changed files with 12 additions and 41 deletions

View File

@ -2270,6 +2270,12 @@ fn resolve_associated_item<'a, 'tcx>(
substs: rcvr_substs,
}
}
::rustc::traits::VtableBuiltin(..) if Some(trait_id) == tcx.lang_items.clone_trait() => {
ty::Instance {
def: ty::InstanceDef::CloneShim(def_id, trait_ref.self_ty()),
substs: rcvr_substs
}
}
_ => bug!("static call to invalid vtable: {:?}", vtbl),
}
}

View File

@ -256,6 +256,7 @@ fn eval_fn_call(
self.dump_local(ret);
Ok(())
}
// FIXME: figure out why we can't just go through the shim
ty::InstanceDef::ClosureOnceShim { .. } => {
let mut args = Vec::new();
for arg in arg_operands {
@ -297,6 +298,9 @@ fn eval_fn_call(
}
Ok(())
}
ty::InstanceDef::FnPtrShim(..) |
ty::InstanceDef::DropGlue(..) |
ty::InstanceDef::CloneShim(..) |
ty::InstanceDef::Item(_) => {
let mut args = Vec::new();
for arg in arg_operands {
@ -394,47 +398,7 @@ fn eval_fn_call(
}
Ok(())
}
ty::InstanceDef::DropGlue(..) => {
assert_eq!(arg_operands.len(), 1);
assert_eq!(sig.abi, Abi::Rust);
let val = self.eval_operand(&arg_operands[0])?;
let ty = self.operand_ty(&arg_operands[0]);
let (_, target) = destination.expect("diverging drop glue");
self.goto_block(target);
// FIXME: deduplicate these matches
let pointee_type = match ty.sty {
ty::TyRawPtr(ref tam) |
ty::TyRef(_, ref tam) => tam.ty,
ty::TyAdt(def, _) if def.is_box() => ty.boxed_ty(),
_ => bug!("can only deref pointer types"),
};
self.drop(val, instance, pointee_type, span)
}
ty::InstanceDef::FnPtrShim(..) => {
trace!("ABI: {}", sig.abi);
let mut args = Vec::new();
for arg in arg_operands {
let arg_val = self.eval_operand(arg)?;
let arg_ty = self.operand_ty(arg);
args.push((arg_val, arg_ty));
}
if M::eval_fn_call(self, instance, destination, arg_operands, span, sig)? {
return Ok(());
}
let arg_locals = self.frame().mir.args_iter();
match sig.abi {
Abi::Rust => {
args.remove(0);
}
Abi::RustCall => {}
_ => unimplemented!(),
};
for (arg_local, (arg_val, arg_ty)) in arg_locals.zip(args) {
let dest = self.eval_lvalue(&mir::Lvalue::Local(arg_local))?;
self.write_value(arg_val, dest, arg_ty)?;
}
Ok(())
}
// cannot use the shim here, because that will only result in infinite recursion
ty::InstanceDef::Virtual(_, idx) => {
let ptr_size = self.memory.pointer_size();
let (_, vtable) = self.eval_operand(&arg_operands[0])?.into_ptr_vtable_pair(

View File

@ -1,3 +1,4 @@
#!/bin/sh
cd "$(dirname "$0")"
sed 's/gcc = "0\.3\.50"/gcc = "=0\.3\.50"/' -i ~/.rustup/toolchains/*/lib/rustlib/src/rust/src/libstd/Cargo.toml
RUSTFLAGS='-Zalways-encode-mir -Zmir-emit-validate=1' xargo build