Skip to content

Commit 66108be

Browse files
authored
Merge pull request #308 from oli-obk/libstd
rustup
2 parents 5d60c61 + f75dd90 commit 66108be

File tree

3 files changed

+12
-41
lines changed

3 files changed

+12
-41
lines changed

src/librustc_mir/interpret/eval_context.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,12 @@ fn resolve_associated_item<'a, 'tcx>(
22702270
substs: rcvr_substs,
22712271
}
22722272
}
2273+
::rustc::traits::VtableBuiltin(..) if Some(trait_id) == tcx.lang_items.clone_trait() => {
2274+
ty::Instance {
2275+
def: ty::InstanceDef::CloneShim(def_id, trait_ref.self_ty()),
2276+
substs: rcvr_substs
2277+
}
2278+
}
22732279
_ => bug!("static call to invalid vtable: {:?}", vtbl),
22742280
}
22752281
}

src/librustc_mir/interpret/terminator/mod.rs

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
256256
self.dump_local(ret);
257257
Ok(())
258258
}
259+
// FIXME: figure out why we can't just go through the shim
259260
ty::InstanceDef::ClosureOnceShim { .. } => {
260261
let mut args = Vec::new();
261262
for arg in arg_operands {
@@ -297,6 +298,9 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
297298
}
298299
Ok(())
299300
}
301+
ty::InstanceDef::FnPtrShim(..) |
302+
ty::InstanceDef::DropGlue(..) |
303+
ty::InstanceDef::CloneShim(..) |
300304
ty::InstanceDef::Item(_) => {
301305
let mut args = Vec::new();
302306
for arg in arg_operands {
@@ -394,47 +398,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
394398
}
395399
Ok(())
396400
}
397-
ty::InstanceDef::DropGlue(..) => {
398-
assert_eq!(arg_operands.len(), 1);
399-
assert_eq!(sig.abi, Abi::Rust);
400-
let val = self.eval_operand(&arg_operands[0])?;
401-
let ty = self.operand_ty(&arg_operands[0]);
402-
let (_, target) = destination.expect("diverging drop glue");
403-
self.goto_block(target);
404-
// FIXME: deduplicate these matches
405-
let pointee_type = match ty.sty {
406-
ty::TyRawPtr(ref tam) |
407-
ty::TyRef(_, ref tam) => tam.ty,
408-
ty::TyAdt(def, _) if def.is_box() => ty.boxed_ty(),
409-
_ => bug!("can only deref pointer types"),
410-
};
411-
self.drop(val, instance, pointee_type, span)
412-
}
413-
ty::InstanceDef::FnPtrShim(..) => {
414-
trace!("ABI: {}", sig.abi);
415-
let mut args = Vec::new();
416-
for arg in arg_operands {
417-
let arg_val = self.eval_operand(arg)?;
418-
let arg_ty = self.operand_ty(arg);
419-
args.push((arg_val, arg_ty));
420-
}
421-
if M::eval_fn_call(self, instance, destination, arg_operands, span, sig)? {
422-
return Ok(());
423-
}
424-
let arg_locals = self.frame().mir.args_iter();
425-
match sig.abi {
426-
Abi::Rust => {
427-
args.remove(0);
428-
}
429-
Abi::RustCall => {}
430-
_ => unimplemented!(),
431-
};
432-
for (arg_local, (arg_val, arg_ty)) in arg_locals.zip(args) {
433-
let dest = self.eval_lvalue(&mir::Lvalue::Local(arg_local))?;
434-
self.write_value(arg_val, dest, arg_ty)?;
435-
}
436-
Ok(())
437-
}
401+
// cannot use the shim here, because that will only result in infinite recursion
438402
ty::InstanceDef::Virtual(_, idx) => {
439403
let ptr_size = self.memory.pointer_size();
440404
let (_, vtable) = self.eval_operand(&arg_operands[0])?.into_ptr_vtable_pair(

xargo/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22
cd "$(dirname "$0")"
3+
sed 's/gcc = "0\.3\.50"/gcc = "=0\.3\.50"/' -i ~/.rustup/toolchains/*/lib/rustlib/src/rust/src/libstd/Cargo.toml
34
RUSTFLAGS='-Zalways-encode-mir -Zmir-emit-validate=1' xargo build

0 commit comments

Comments
 (0)