]> git.lizzy.rs Git - rust.git/commitdiff
Rustup
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 5 Sep 2017 15:18:48 +0000 (17:18 +0200)
committerRalf Jung <post@ralfj.de>
Wed, 6 Sep 2017 08:10:15 +0000 (10:10 +0200)
src/librustc_mir/interpret/eval_context.rs
src/librustc_mir/interpret/lvalue.rs
src/librustc_mir/interpret/step.rs
tests/run-pass-fullmir/unsized-tuple-impls.rs

index 44777caa4f5d2f8e085c9990a3ef27135dd03064..bc227fcc3985ed2bbf94ffe1445cfc22e6bab7f3 100644 (file)
@@ -467,8 +467,8 @@ fn collect_storage_annotations<'tcx>(mir: &'tcx mir::Mir<'tcx>) -> HashSet<mir::
             for block in mir.basic_blocks() {
                 for stmt in block.statements.iter() {
                     match stmt.kind {
-                        StorageLive(mir::Lvalue::Local(local)) |
-                        StorageDead(mir::Lvalue::Local(local)) => {
+                        StorageLive(local) |
+                        StorageDead(local) => {
                             set.insert(local);
                         }
                         _ => {}
index f26f5adfff9652d56ac9183607ea01b61501ea68..3342be7300e7762bca572bfca99339dbe58ec290 100644 (file)
@@ -3,7 +3,7 @@
 use rustc::ty::{self, Ty};
 use rustc_data_structures::indexed_vec::Idx;
 
-use super::{EvalResult, EvalContext, MemoryPointer, PrimVal, Value, Pointer, Machine, PtrAndAlign};
+use super::{EvalResult, EvalContext, MemoryPointer, PrimVal, Value, Pointer, Machine, PtrAndAlign, ValTy};
 
 #[derive(Copy, Clone, Debug)]
 pub enum Lvalue {
@@ -400,7 +400,7 @@ pub(super) fn eval_lvalue_projection(
         &mut self,
         base: Lvalue,
         base_ty: Ty<'tcx>,
-        proj_elem: &mir::ProjectionElem<'tcx, mir::Operand<'tcx>, Ty<'tcx>>,
+        proj_elem: &mir::ProjectionElem<'tcx, mir::Local, Ty<'tcx>>,
     ) -> EvalResult<'tcx, Lvalue> {
         use rustc::mir::ProjectionElem::*;
         let (ptr, extra) = match *proj_elem {
@@ -439,9 +439,10 @@ pub(super) fn eval_lvalue_projection(
                 return self.val_to_lvalue(val, pointee_type);
             }
 
-            Index(ref operand) => {
-                let n_ptr = self.eval_operand(operand)?;
-                let n = self.value_to_primval(n_ptr)?.to_u64()?;
+            Index(local) => {
+                let value = self.frame().get_local(local)?;
+                let ty = self.tcx.types.usize;
+                let n = self.value_to_primval(ValTy { value, ty })?.to_u64()?;
                 return self.lvalue_index(base, base_ty, n);
             }
 
index ea90e39489d5e3e9f8a77288e9e355443848e34e..e7d5a83532b312b79fbf0a2ac516dac79e6f27ee 100644 (file)
@@ -145,22 +145,15 @@ fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> EvalResult<'tcx> {
                 }
             }
 
-            // Mark locals as dead or alive.
-            StorageLive(ref lvalue) |
-            StorageDead(ref lvalue) => {
-                let (frame, local) =
-                    match self.eval_lvalue(lvalue)? {
-                        Lvalue::Local { frame, local } if self.cur_frame() == frame => (
-                            frame,
-                            local,
-                        ),
-                        _ => return err!(Unimplemented("Storage annotations must refer to locals of the topmost stack frame.".to_owned())), // FIXME maybe this should get its own error type
-                    };
-                let old_val = match stmt.kind {
-                    StorageLive(_) => self.stack[frame].storage_live(local)?,
-                    StorageDead(_) => self.stack[frame].storage_dead(local)?,
-                    _ => bug!("We already checked that we are a storage stmt"),
-                };
+            // Mark locals as alive
+            StorageLive(local) => {
+                let old_val = self.frame_mut().storage_live(local)?;
+                self.deallocate_local(old_val)?;
+            }
+
+            // Mark locals as dead
+            StorageDead(local) => {
+                let old_val = self.frame_mut().storage_dead(local)?;
                 self.deallocate_local(old_val)?;
             }
 
index ccb6883e8733a5b8d660c2b6e8f3fac2ceb22238..acaedebbf9b8496f9c8ebd21f3feb1eff3577f13 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// compile-flags: -Zmir-emit-validate=0
+
 #![feature(unsized_tuple_coercion)]
 use std::mem;