@@ -14,13 +14,12 @@ use std::ptr;
14
14
15
15
use rustc_ast:: ast:: Mutability ;
16
16
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
17
- use rustc_hir:: def_id:: DefId ;
18
- use rustc_middle:: ty:: { self , Instance , ParamEnv , TyCtxt } ;
17
+ use rustc_middle:: ty:: { Instance , ParamEnv , TyCtxt } ;
19
18
use rustc_target:: abi:: { Align , HasDataLayout , Size , TargetDataLayout } ;
20
19
21
20
use super :: {
22
- AllocId , AllocMap , Allocation , AllocationExtra , CheckInAllocMsg , GlobalAlloc , GlobalId ,
23
- InterpResult , Machine , MayLeak , Pointer , PointerArithmetic , Scalar ,
21
+ AllocId , AllocMap , Allocation , AllocationExtra , CheckInAllocMsg , GlobalAlloc , InterpResult ,
22
+ Machine , MayLeak , Pointer , PointerArithmetic , Scalar ,
24
23
} ;
25
24
use crate :: util:: pretty;
26
25
@@ -119,17 +118,6 @@ pub struct Memory<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
119
118
pub tcx : TyCtxt < ' tcx > ,
120
119
}
121
120
122
- /// Return the `tcx` allocation containing the initial value of the given static
123
- pub fn get_static ( tcx : TyCtxt < ' tcx > , def_id : DefId ) -> InterpResult < ' tcx , & ' tcx Allocation > {
124
- trace ! ( "get_static: Need to compute {:?}" , def_id) ;
125
- let instance = Instance :: mono ( tcx, def_id) ;
126
- let gid = GlobalId { instance, promoted : None } ;
127
- // Use the raw query here to break validation cycles. Later uses of the static
128
- // will call the full query anyway.
129
- let raw_const = tcx. const_eval_raw ( ty:: ParamEnv :: reveal_all ( ) . and ( gid) ) ?;
130
- Ok ( tcx. global_alloc ( raw_const. alloc_id ) . unwrap_memory ( ) )
131
- }
132
-
133
121
impl < ' mir , ' tcx , M : Machine < ' mir , ' tcx > > HasDataLayout for Memory < ' mir , ' tcx , M > {
134
122
#[ inline]
135
123
fn data_layout ( & self ) -> & TargetDataLayout {
@@ -489,7 +477,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
489
477
throw_unsup ! ( ReadExternStatic ( def_id) ) ;
490
478
}
491
479
492
- ( get_static ( tcx, def_id) ?, Some ( def_id) )
480
+ ( tcx. eval_static_initializer ( def_id) ?, Some ( def_id) )
493
481
}
494
482
} ;
495
483
M :: before_access_global ( memory_extra, id, alloc, def_id, is_write) ?;
0 commit comments