]> git.lizzy.rs Git - rust.git/commitdiff
Simplify `write_value_to_ptr`
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 28 Aug 2017 14:06:49 +0000 (16:06 +0200)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 28 Aug 2017 14:06:49 +0000 (16:06 +0200)
src/librustc_mir/interpret/eval_context.rs

index 39ead337906f88d4dee25f128b49d2d0ba45c5fa..044f37947d30e276b3a7e62e5dec35796acf0366 100644 (file)
@@ -1622,20 +1622,13 @@ pub fn write_value_to_ptr(
             }
             Value::ByVal(primval) => {
                 let size = self.type_size(dest_ty)?.expect("dest type must be sized");
-                // TODO: This fn gets called with sizes like 0 and 6, which cannot be a primitive type
-                // and hence is not supported by write_primval.
-                // (E.g. in the arrays.rs testcase.)  That seems to only happen for Undef though,
-                // so we special-case that here.
-                match primval {
-                    PrimVal::Undef => {
-                        self.memory.mark_definedness(dest, size, false)?;
-                    }
-                    _ => {
-                        // TODO: Do we need signedness?
-                        self.memory.write_primval(dest.to_ptr()?, primval, size, false)?;
-                    }
+                if size == 0 {
+                    assert!(primval.is_undef());
+                    Ok(())
+                } else {
+                    // TODO: Do we need signedness?
+                    self.memory.write_primval(dest.to_ptr()?, primval, size, false)
                 }
-                Ok(())
             }
             Value::ByValPair(a, b) => self.write_pair_to_ptr(a, b, dest.to_ptr()?, dest_ty),
         }