Skip to content

Commit 92a4333

Browse files
committed
Rustup
1 parent c201aeb commit 92a4333

File tree

4 files changed

+19
-23
lines changed

4 files changed

+19
-23
lines changed

src/librustc_mir/interpret/eval_context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
467467
for block in mir.basic_blocks() {
468468
for stmt in block.statements.iter() {
469469
match stmt.kind {
470-
StorageLive(mir::Lvalue::Local(local)) |
471-
StorageDead(mir::Lvalue::Local(local)) => {
470+
StorageLive(local) |
471+
StorageDead(local) => {
472472
set.insert(local);
473473
}
474474
_ => {}

src/librustc_mir/interpret/lvalue.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc::ty::layout::{Size, Align};
33
use rustc::ty::{self, Ty};
44
use rustc_data_structures::indexed_vec::Idx;
55

6-
use super::{EvalResult, EvalContext, MemoryPointer, PrimVal, Value, Pointer, Machine, PtrAndAlign};
6+
use super::{EvalResult, EvalContext, MemoryPointer, PrimVal, Value, Pointer, Machine, PtrAndAlign, ValTy};
77

88
#[derive(Copy, Clone, Debug)]
99
pub enum Lvalue {
@@ -400,7 +400,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
400400
&mut self,
401401
base: Lvalue,
402402
base_ty: Ty<'tcx>,
403-
proj_elem: &mir::ProjectionElem<'tcx, mir::Operand<'tcx>, Ty<'tcx>>,
403+
proj_elem: &mir::ProjectionElem<'tcx, mir::Local, Ty<'tcx>>,
404404
) -> EvalResult<'tcx, Lvalue> {
405405
use rustc::mir::ProjectionElem::*;
406406
let (ptr, extra) = match *proj_elem {
@@ -439,9 +439,10 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
439439
return self.val_to_lvalue(val, pointee_type);
440440
}
441441

442-
Index(ref operand) => {
443-
let n_ptr = self.eval_operand(operand)?;
444-
let n = self.value_to_primval(n_ptr)?.to_u64()?;
442+
Index(local) => {
443+
let value = self.frame().get_local(local)?;
444+
let ty = self.tcx.types.usize;
445+
let n = self.value_to_primval(ValTy { value, ty })?.to_u64()?;
445446
return self.lvalue_index(base, base_ty, n);
446447
}
447448

src/librustc_mir/interpret/step.rs

+9-16
Original file line numberDiff line numberDiff line change
@@ -145,22 +145,15 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
145145
}
146146
}
147147

148-
// Mark locals as dead or alive.
149-
StorageLive(ref lvalue) |
150-
StorageDead(ref lvalue) => {
151-
let (frame, local) =
152-
match self.eval_lvalue(lvalue)? {
153-
Lvalue::Local { frame, local } if self.cur_frame() == frame => (
154-
frame,
155-
local,
156-
),
157-
_ => 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
158-
};
159-
let old_val = match stmt.kind {
160-
StorageLive(_) => self.stack[frame].storage_live(local)?,
161-
StorageDead(_) => self.stack[frame].storage_dead(local)?,
162-
_ => bug!("We already checked that we are a storage stmt"),
163-
};
148+
// Mark locals as alive
149+
StorageLive(local) => {
150+
let old_val = self.frame_mut().storage_live(local)?;
151+
self.deallocate_local(old_val)?;
152+
}
153+
154+
// Mark locals as dead
155+
StorageDead(local) => {
156+
let old_val = self.frame_mut().storage_dead(local)?;
164157
self.deallocate_local(old_val)?;
165158
}
166159

tests/run-pass-fullmir/unsized-tuple-impls.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// compile-flags: -Zmir-emit-validate=0
12+
1113
#![feature(unsized_tuple_coercion)]
1214
use std::mem;
1315

0 commit comments

Comments
 (0)