1
1
use std:: collections:: HashMap ;
2
2
3
- use rustc:: ty:: { layout:: { Size , Align } , TyCtxt } ;
3
+ use rustc:: ty:: layout:: { Size , Align } ;
4
4
use rustc_mir:: interpret:: { Pointer , Memory } ;
5
5
use crate :: stacked_borrows:: Tag ;
6
6
use crate :: * ;
@@ -13,12 +13,11 @@ pub struct EnvVars {
13
13
impl EnvVars {
14
14
pub ( crate ) fn init < ' mir , ' tcx > (
15
15
ecx : & mut InterpCx < ' mir , ' tcx , Evaluator < ' tcx > > ,
16
- tcx : & TyCtxt < ' tcx > ,
17
16
communicate : bool ,
18
17
) {
19
18
if communicate {
20
19
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 ( ) ) ;
22
21
ecx. machine . env_vars . map . insert ( name. into_bytes ( ) , value) ;
23
22
}
24
23
}
@@ -40,8 +39,8 @@ impl EnvVars {
40
39
pub ( crate ) fn alloc_env_value < ' mir , ' tcx > (
41
40
bytes : & [ u8 ] ,
42
41
memory : & mut Memory < ' mir , ' tcx , Evaluator < ' tcx > > ,
43
- tcx : & TyCtxt < ' tcx > ,
44
42
) -> Pointer < Tag > {
43
+ let tcx = { memory. tcx . tcx } ;
45
44
let length = bytes. len ( ) as u64 ;
46
45
// `+1` for the null terminator.
47
46
let ptr = memory. allocate (
@@ -51,11 +50,11 @@ pub(crate) fn alloc_env_value<'mir, 'tcx>(
51
50
) ;
52
51
// We just allocated these, so the write cannot fail.
53
52
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 ( ) ;
55
54
let trailing_zero_ptr = ptr. offset (
56
55
Size :: from_bytes ( length) ,
57
- tcx,
56
+ & tcx,
58
57
) . unwrap ( ) ;
59
- alloc. write_bytes ( tcx, trailing_zero_ptr, & [ 0 ] ) . unwrap ( ) ;
58
+ alloc. write_bytes ( & tcx, trailing_zero_ptr, & [ 0 ] ) . unwrap ( ) ;
60
59
ptr
61
60
}
0 commit comments