@@ -13,8 +13,8 @@ use std::fmt;
13
13
use std:: ptr;
14
14
15
15
use rustc_ast:: ast:: Mutability ;
16
- use rustc_hir:: def_id:: DefId ;
17
16
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
17
+ use rustc_hir:: def_id:: DefId ;
18
18
use rustc_middle:: ty:: { self , Instance , ParamEnv , TyCtxt } ;
19
19
use rustc_target:: abi:: { Align , HasDataLayout , Size , TargetDataLayout } ;
20
20
@@ -119,12 +119,8 @@ pub struct Memory<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
119
119
pub tcx : TyCtxt < ' tcx > ,
120
120
}
121
121
122
-
123
122
/// Return the `tcx` allocation containing the initial value of the given static
124
- pub fn get_static (
125
- tcx : TyCtxt < ' tcx > ,
126
- def_id : DefId ,
127
- ) -> InterpResult < ' tcx , & ' tcx Allocation > {
123
+ pub fn get_static ( tcx : TyCtxt < ' tcx > , def_id : DefId ) -> InterpResult < ' tcx , & ' tcx Allocation > {
128
124
trace ! ( "get_static: Need to compute {:?}" , def_id) ;
129
125
let instance = Instance :: mono ( tcx, def_id) ;
130
126
let gid = GlobalId { instance, promoted : None } ;
@@ -162,7 +158,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
162
158
///
163
159
/// This function can fail only if `ptr` points to an `extern static`.
164
160
#[ inline]
165
- pub fn global_base_pointer ( & self , mut ptr : Pointer ) -> InterpResult < ' tcx , Pointer < M :: PointerTag > > {
161
+ pub fn global_base_pointer (
162
+ & self ,
163
+ mut ptr : Pointer ,
164
+ ) -> InterpResult < ' tcx , Pointer < M :: PointerTag > > {
166
165
// We need to handle `extern static`.
167
166
let ptr = match self . tcx . get_global_alloc ( ptr. alloc_id ) {
168
167
Some ( GlobalAlloc :: Static ( def_id) ) if self . tcx . is_thread_local_static ( def_id) => {
@@ -197,7 +196,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
197
196
}
198
197
} ;
199
198
// Functions are global allocations, so make sure we get the right base pointer.
200
- // We know this is not an `extern static` so this cannmot fail.
199
+ // We know this is not an `extern static` so this cannot fail.
201
200
self . global_base_pointer ( Pointer :: from ( id) ) . unwrap ( )
202
201
}
203
202
@@ -659,7 +658,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
659
658
if ptr. offset . bytes ( ) != 0 {
660
659
throw_ub ! ( InvalidFunctionPointer ( ptr. erase_tag( ) ) )
661
660
}
662
- self . get_fn_alloc ( ptr. alloc_id ) . ok_or_else ( || err_ub ! ( InvalidFunctionPointer ( ptr. erase_tag( ) ) ) . into ( ) )
661
+ self . get_fn_alloc ( ptr. alloc_id )
662
+ . ok_or_else ( || err_ub ! ( InvalidFunctionPointer ( ptr. erase_tag( ) ) ) . into ( ) )
663
663
}
664
664
665
665
pub fn mark_immutable ( & mut self , id : AllocId ) -> InterpResult < ' tcx > {
0 commit comments