From 828aebfe3a2a4beef1dd149f61ce26057d52ce70 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 3 Aug 2018 12:40:03 +0200 Subject: [PATCH] Unify API of `Scalar` and `ScalarMaybeUndef` --- src/librustc/mir/interpret/value.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index 71e3ac48d5b..f569f4def14 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -103,6 +103,10 @@ impl<'tcx> Scalar { ScalarMaybeUndef::Scalar(self).to_value_with_len(len, cx) } + pub fn to_value_with_vtable(self, vtable: Pointer) -> Value { + ScalarMaybeUndef::Scalar(self).to_value_with_vtable(vtable) + } + pub fn ptr_signed_offset(self, i: i64, cx: C) -> EvalResult<'tcx, Self> { let layout = cx.data_layout(); match self { @@ -207,14 +211,14 @@ impl ScalarMaybeUndef { } pub fn to_value_with_len(self, len: u64, cx: C) -> Value { - Value::ScalarPair(self.into(), Scalar::Bits { + Value::ScalarPair(self, Scalar::Bits { bits: len as u128, size: cx.data_layout().pointer_size.bytes() as u8, }.into()) } pub fn to_value_with_vtable(self, vtable: Pointer) -> Value { - Value::ScalarPair(self.into(), Scalar::Ptr(vtable).into()) + Value::ScalarPair(self, Scalar::Ptr(vtable).into()) } pub fn ptr_offset(self, i: Size, cx: C) -> EvalResult<'tcx, Self> {