@@ -14,13 +14,12 @@ use std::ptr;
1414
1515use rustc_ast:: ast:: Mutability ;
1616use 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 } ;
1918use rustc_target:: abi:: { Align , HasDataLayout , Size , TargetDataLayout } ;
2019
2120use 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 ,
2423} ;
2524use crate :: util:: pretty;
2625
@@ -119,17 +118,6 @@ pub struct Memory<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
119118 pub tcx : TyCtxt < ' tcx > ,
120119}
121120
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-
133121impl < ' mir , ' tcx , M : Machine < ' mir , ' tcx > > HasDataLayout for Memory < ' mir , ' tcx , M > {
134122 #[ inline]
135123 fn data_layout ( & self ) -> & TargetDataLayout {
@@ -489,7 +477,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
489477 throw_unsup ! ( ReadExternStatic ( def_id) ) ;
490478 }
491479
492- ( get_static ( tcx, def_id) ?, Some ( def_id) )
480+ ( tcx. eval_static_initializer ( def_id) ?, Some ( def_id) )
493481 }
494482 } ;
495483 M :: before_access_global ( memory_extra, id, alloc, def_id, is_write) ?;
0 commit comments