about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2017-09-16 12:08:26 +0200
committerRalf Jung <post@ralfj.de>2017-09-16 12:08:26 +0200
commit8509dbbafe1a08ea5cee367bb1599e0bb09a2a2d (patch)
tree12860dcfc6e3b0214b4326d85c34b1e6a8b35e08 /src
parent2ea6663440b1a26396caf328aa36497224799abf (diff)
downloadrust-8509dbbafe1a08ea5cee367bb1599e0bb09a2a2d.tar.gz
rust-8509dbbafe1a08ea5cee367bb1599e0bb09a2a2d.zip
validation: allow undef integers and raw pointers, as a crude work-around
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/interpret/validation.rs17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/librustc_mir/interpret/validation.rs b/src/librustc_mir/interpret/validation.rs
index af245a0b2a6..9be9341ee23 100644
--- a/src/librustc_mir/interpret/validation.rs
+++ b/src/librustc_mir/interpret/validation.rs
@@ -493,18 +493,11 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
             match query.ty.sty {
                 TyInt(_) | TyUint(_) | TyRawPtr(_) => {
                     if mode.acquiring() {
-                        // Make sure there is no undef
+                        // Make sure we can read this.
                         let val = self.read_lvalue(query.lval.1)?;
-                        // This is essentially value_to_primval with support for fat pointers
-                        let has_undef = match self.follow_by_ref_value(val, query.ty)? {
-                            Value::ByRef { .. } => bug!("follow_by_ref_value can't result in `ByRef`"),
-                            Value::ByVal(primval) => primval.is_undef(),
-                            Value::ByValPair(primval1, primval2) =>
-                                primval1.is_undef() || primval2.is_undef()
-                        };
-                        if has_undef {
-                            return err!(ReadUndefBytes);
-                        }
+                        self.follow_by_ref_value(val, query.ty)?;
+                        // FIXME: It would be great to rule out Undef here, but that doesn't actually work.
+                        // Passing around undef data is a thing that e.g. Vec::extend_with does.
                     }
                     Ok(())
                 }
@@ -512,7 +505,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
                     if mode.acquiring() {
                         let val = self.read_lvalue(query.lval.1)?;
                         let val = self.value_to_primval(ValTy { value: val, ty: query.ty })?;
-                        let _val = val.to_bytes()?;
+                        val.to_bytes()?;
                         // TODO: Check if these are valid bool/float/codepoint/UTF-8
                     }
                     Ok(())