fix some nits

This commit is contained in:
Ralf Jung 2017-06-01 11:01:55 -07:00
parent e6eaf2083a
commit db6ce463fe
2 changed files with 6 additions and 4 deletions

View File

@ -453,7 +453,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
) -> EvalResult<'tcx> {
::log_settings::settings().indentation += 1;
/// Return the set of locals that have a stroage annotation anywhere
/// Return the set of locals that have a storage annotation anywhere
fn collect_storage_annotations<'tcx>(mir: &'tcx mir::Mir<'tcx>) -> HashSet<mir::Local> {
use rustc::mir::StatementKind::*;
@ -475,10 +475,12 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
// `Value` for that.
let annotated_locals = collect_storage_annotations(mir);
let num_locals = mir.local_decls.len() - 1;
let mut locals = Vec::with_capacity(num_locals);
let mut locals = vec![None; num_locals];
for i in 0..num_locals {
let local = mir::Local::new(i+1);
locals.push(if annotated_locals.contains(&local) { None } else { Some(Value::ByVal(PrimVal::Undef)) });
if !annotated_locals.contains(&local) {
locals[i] = Some(Value::ByVal(PrimVal::Undef));
}
}
self.stack.push(Frame {

View File

@ -130,7 +130,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
Ok(Value::ByRef(ptr))
}
Lvalue::Local { frame, local, field } => {
Ok(self.stack[frame].get_local(local, field.map(|(i, _)| i))?)
self.stack[frame].get_local(local, field.map(|(i, _)| i))
}
Lvalue::Global(cid) => {
Ok(self.globals.get(&cid).expect("global not cached").value)