]> git.lizzy.rs Git - rust.git/commitdiff
Comparing non-pointer-size types should be possible
authorOliver Schneider <github35764891676564198441@oli-obk.de>
Wed, 30 May 2018 12:30:15 +0000 (14:30 +0200)
committerOliver Schneider <github35764891676564198441@oli-obk.de>
Sun, 3 Jun 2018 11:08:51 +0000 (13:08 +0200)
src/operator.rs

index 721b4f0bfddabfac5b1138ddf5ced28b769870aa..f36e749dc9279a010a24d8717c1cd25205619086 100644 (file)
@@ -52,11 +52,13 @@ fn ptr_op(
             16 => I128,
             _ => unreachable!(),
         }, true);
-        let left_kind = match self.layout_of(left_ty)?.abi {
+        let left_layout = self.layout_of(left_ty)?;
+        let left_kind = match left_layout.abi {
             ty::layout::Abi::Scalar(ref scalar) => scalar.value,
             _ => Err(EvalErrorKind::TypeNotPrimitive(left_ty))?,
         };
-        let right_kind = match self.layout_of(right_ty)?.abi {
+        let right_layout = self.layout_of(right_ty)?;
+        let right_kind = match right_layout.abi {
             ty::layout::Abi::Scalar(ref scalar) => scalar.value,
             _ => Err(EvalErrorKind::TypeNotPrimitive(right_ty))?,
         };
@@ -77,7 +79,7 @@ fn ptr_op(
             Eq if left_kind == right_kind => {
                 let result = match (left, right) {
                     (Scalar::Bits { .. }, Scalar::Bits { .. }) => {
-                        left.to_bits(self.memory.pointer_size())? == right.to_bits(self.memory.pointer_size())?
+                        left.to_bits(left_layout.size)? == right.to_bits(right_layout.size)?
                     },
                     (Scalar::Ptr(left), Scalar::Ptr(right)) => left == right,
                     _ => false,
@@ -87,7 +89,7 @@ fn ptr_op(
             Ne if left_kind == right_kind => {
                 let result = match (left, right) {
                     (Scalar::Bits { .. }, Scalar::Bits { .. }) => {
-                        left.to_bits(self.memory.pointer_size())? != right.to_bits(self.memory.pointer_size())?
+                        left.to_bits(left_layout.size)? != right.to_bits(right_layout.size)?
                     },
                     (Scalar::Ptr(left), Scalar::Ptr(right)) => left != right,
                     _ => true,