Evaluator::new(config.communicate),
MemoryExtra::new(StdRng::seed_from_u64(config.seed.unwrap_or(0)), config.validate),
);
+
// Complete initialization.
- EnvVars::init(&mut ecx, &tcx, config.communicate);
+ EnvVars::init(&mut ecx, config.communicate);
+
// Setup first stack-frame
let main_instance = ty::Instance::mono(ecx.tcx.tcx, main_id);
let main_mir = ecx.load_mir(main_instance.def)?;
use std::collections::HashMap;
-use rustc::ty::{layout::{Size, Align}, TyCtxt};
+use rustc::ty::layout::{Size, Align};
use rustc_mir::interpret::{Pointer, Memory};
use crate::stacked_borrows::Tag;
use crate::*;
impl EnvVars {
pub(crate) fn init<'mir, 'tcx>(
ecx: &mut InterpCx<'mir, 'tcx, Evaluator<'tcx>>,
- tcx: &TyCtxt<'tcx>,
communicate: bool,
) {
if communicate {
for (name, value) in std::env::vars() {
- let value = alloc_env_value(value.as_bytes(), ecx.memory_mut(), tcx);
+ let value = alloc_env_value(value.as_bytes(), ecx.memory_mut());
ecx.machine.env_vars.map.insert(name.into_bytes(), value);
}
}
pub(crate) fn alloc_env_value<'mir, 'tcx>(
bytes: &[u8],
memory: &mut Memory<'mir, 'tcx, Evaluator<'tcx>>,
- tcx: &TyCtxt<'tcx>,
) -> Pointer<Tag> {
+ let tcx = {memory.tcx.tcx};
let length = bytes.len() as u64;
// `+1` for the null terminator.
let ptr = memory.allocate(
);
// We just allocated these, so the write cannot fail.
let alloc = memory.get_mut(ptr.alloc_id).unwrap();
- alloc.write_bytes(tcx, ptr, &bytes).unwrap();
+ alloc.write_bytes(&tcx, ptr, &bytes).unwrap();
let trailing_zero_ptr = ptr.offset(
Size::from_bytes(length),
- tcx,
+ &tcx,
).unwrap();
- alloc.write_bytes(tcx, trailing_zero_ptr, &[0]).unwrap();
+ alloc.write_bytes(&tcx, trailing_zero_ptr, &[0]).unwrap();
ptr
}
}
}
if let Some((name, value)) = new {
- let value_copy = alloc_env_value(&value, this.memory_mut(), tcx);
+ let value_copy = alloc_env_value(&value, this.memory_mut());
if let Some(var) = this.machine.env_vars.set(name.to_owned(), value_copy) {
this.memory_mut().deallocate(var, None, MiriMemoryKind::Env.into())?;
}