Skip to content

Commit 451a09a

Browse files
committed
Remove tcx parameter for EnvVars::alloc_env_value
1 parent 46f902b commit 451a09a

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/eval.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
3939
Evaluator::new(config.communicate),
4040
MemoryExtra::new(StdRng::seed_from_u64(config.seed.unwrap_or(0)), config.validate),
4141
);
42+
4243
// Complete initialization.
43-
EnvVars::init(&mut ecx, &tcx, config.communicate);
44+
EnvVars::init(&mut ecx, config.communicate);
45+
4446
// Setup first stack-frame
4547
let main_instance = ty::Instance::mono(ecx.tcx.tcx, main_id);
4648
let main_mir = ecx.load_mir(main_instance.def)?;

src/shims/env.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::HashMap;
22

3-
use rustc::ty::{layout::{Size, Align}, TyCtxt};
3+
use rustc::ty::layout::{Size, Align};
44
use rustc_mir::interpret::{Pointer, Memory};
55
use crate::stacked_borrows::Tag;
66
use crate::*;
@@ -13,12 +13,11 @@ pub struct EnvVars {
1313
impl EnvVars {
1414
pub(crate) fn init<'mir, 'tcx>(
1515
ecx: &mut InterpCx<'mir, 'tcx, Evaluator<'tcx>>,
16-
tcx: &TyCtxt<'tcx>,
1716
communicate: bool,
1817
) {
1918
if communicate {
2019
for (name, value) in std::env::vars() {
21-
let value = alloc_env_value(value.as_bytes(), ecx.memory_mut(), tcx);
20+
let value = alloc_env_value(value.as_bytes(), ecx.memory_mut());
2221
ecx.machine.env_vars.map.insert(name.into_bytes(), value);
2322
}
2423
}
@@ -40,8 +39,8 @@ impl EnvVars {
4039
pub(crate) fn alloc_env_value<'mir, 'tcx>(
4140
bytes: &[u8],
4241
memory: &mut Memory<'mir, 'tcx, Evaluator<'tcx>>,
43-
tcx: &TyCtxt<'tcx>,
4442
) -> Pointer<Tag> {
43+
let tcx = {memory.tcx.tcx};
4544
let length = bytes.len() as u64;
4645
// `+1` for the null terminator.
4746
let ptr = memory.allocate(
@@ -51,11 +50,11 @@ pub(crate) fn alloc_env_value<'mir, 'tcx>(
5150
);
5251
// We just allocated these, so the write cannot fail.
5352
let alloc = memory.get_mut(ptr.alloc_id).unwrap();
54-
alloc.write_bytes(tcx, ptr, &bytes).unwrap();
53+
alloc.write_bytes(&tcx, ptr, &bytes).unwrap();
5554
let trailing_zero_ptr = ptr.offset(
5655
Size::from_bytes(length),
57-
tcx,
56+
&tcx,
5857
).unwrap();
59-
alloc.write_bytes(tcx, trailing_zero_ptr, &[0]).unwrap();
58+
alloc.write_bytes(&tcx, trailing_zero_ptr, &[0]).unwrap();
6059
ptr
6160
}

src/shims/foreign_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
466466
}
467467
}
468468
if let Some((name, value)) = new {
469-
let value_copy = alloc_env_value(&value, this.memory_mut(), tcx);
469+
let value_copy = alloc_env_value(&value, this.memory_mut());
470470
if let Some(var) = this.machine.env_vars.set(name.to_owned(), value_copy) {
471471
this.memory_mut().deallocate(var, None, MiriMemoryKind::Env.into())?;
472472
}

0 commit comments

Comments
 (0)