11use std:: collections:: HashMap ;
22
3- use rustc:: ty:: { layout:: { Size , Align } , TyCtxt } ;
3+ use rustc:: ty:: layout:: { Size , Align } ;
44use rustc_mir:: interpret:: { Pointer , Memory } ;
55use crate :: stacked_borrows:: Tag ;
66use crate :: * ;
@@ -13,12 +13,11 @@ pub struct EnvVars {
1313impl 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 {
4039pub ( 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}
0 commit comments