Skip to content

Commit ff080a9

Browse files
committed
1 parent 7ade1c4 commit ff080a9

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/eval_context.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
623623
(Value::ByValPair(data, _), false) => {
624624
self.write_value(ValTy { value: Value::ByVal(data), ty: dest_ty }, dest)?;
625625
},
626-
(Value::ByVal(_), _) => bug!("expected fat ptr"),
626+
(Value::ByVal(v), false) => {
627+
self.write_value(ValTy { value: Value::ByVal(v), ty: dest_ty }, dest)?;
628+
}
629+
(Value::ByVal(_), true) => bug!("expected fat ptr"),
627630
}
628631
} else {
629632
// First, try casting
@@ -711,7 +714,15 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
711714
fn type_is_fat_ptr(&self, ty: Ty<'tcx>) -> bool {
712715
match ty.sty {
713716
ty::TyRawPtr(ref tam) |
714-
ty::TyRef(_, ref tam) => !self.type_is_sized(tam.ty),
717+
ty::TyRef(_, ref tam) => {
718+
if let ty::TyForeign(def_id) = tam.ty.sty {
719+
if "Opaque" == self.tcx.item_name(def_id) {
720+
// TODO make this more picky. We want it to only match std::alloc::Opaque.
721+
return false;
722+
}
723+
}
724+
!self.type_is_sized(tam.ty)
725+
}
715726
ty::TyAdt(def, _) if def.is_box() => !self.type_is_sized(ty.boxed_ty()),
716727
_ => false,
717728
}

src/terminator/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
702702
return Ok(());
703703
}
704704

705-
"alloc::heap::::__rust_alloc" => {
705+
"alloc::alloc::::__rust_alloc" => {
706706
let usize = self.tcx.types.usize;
707707
let size = self.value_to_primval(args[0], usize)?.to_u64()?;
708708
let align = self.value_to_primval(args[1], usize)?.to_u64()?;
@@ -716,7 +716,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
716716
return Ok(());
717717
}
718718

719-
"alloc::heap::::__rust_alloc_zeroed" => {
719+
"alloc::alloc::::__rust_alloc_zeroed" => {
720720
let usize = self.tcx.types.usize;
721721
let size = self.value_to_primval(args[0], usize)?.to_u64()?;
722722
let align = self.value_to_primval(args[1], usize)?.to_u64()?;
@@ -798,7 +798,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
798798
return Ok(());
799799
}
800800

801-
"alloc::heap::::__rust_realloc" => {
801+
"alloc::alloc::::__rust_realloc" => {
802802
let (lval, block) = destination.expect("realloc() does not diverge");
803803
let dest_ptr = self.force_allocation(lval)?.to_ptr()?;
804804

@@ -809,17 +809,16 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
809809

810810
let usize = self.tcx.types.usize;
811811
let _old_size = self.value_to_primval(args[1], usize)?.to_u64()?;
812-
let _old_align = self.value_to_primval(args[2], usize)?.to_u64()?;
812+
let align = self.value_to_primval(args[2], usize)?.to_u64()?;
813813
let new_size = self.value_to_primval(args[3], usize)?.to_u64()?;
814-
let new_align = self.value_to_primval(args[4], usize)?.to_u64()?;
815814

816-
let new_ptr = self.memory.reallocate(ptr, new_size, new_align)?;
815+
let new_ptr = self.memory.reallocate(ptr, new_size, align)?;
817816
self.memory.write_ptr(dest_ptr, new_ptr)?;
818817
self.goto_block(block);
819818
return Ok(());
820819
}
821820

822-
"alloc::heap::::__rust_dealloc" => {
821+
"alloc::alloc::::__rust_dealloc" => {
823822
let (_lval, block) = destination.expect("dealloc() does not diverge");
824823

825824
let ptr = match args[0] {

0 commit comments

Comments
 (0)