@@ -320,15 +320,16 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
320320 /// this machine use the same pointer tag, so it is indirected through
321321 /// `M::static_with_default_tag`.
322322 fn get_static_alloc (
323- tcx : TyCtxtAt < ' a , ' tcx , ' tcx > ,
324323 id : AllocId ,
324+ tcx : TyCtxtAt < ' a , ' tcx , ' tcx > ,
325+ memory_extra : & M :: MemoryExtra ,
325326 ) -> EvalResult < ' tcx , Cow < ' tcx , Allocation < M :: PointerTag , M :: AllocExtra > > > {
326327 let alloc = tcx. alloc_map . lock ( ) . get ( id) ;
327328 let def_id = match alloc {
328329 Some ( AllocType :: Memory ( mem) ) => {
329330 // We got tcx memory. Let the machine figure out whether and how to
330331 // turn that into memory with the right pointer tag.
331- return Ok ( M :: adjust_static_allocation ( mem) )
332+ return Ok ( M :: adjust_static_allocation ( mem, memory_extra ) )
332333 }
333334 Some ( AllocType :: Function ( ..) ) => {
334335 return err ! ( DerefFunctionPointer )
@@ -342,7 +343,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
342343 // We got a "lazy" static that has not been computed yet, do some work
343344 trace ! ( "static_alloc: Need to compute {:?}" , def_id) ;
344345 if tcx. is_foreign_item ( def_id) {
345- return M :: find_foreign_static ( tcx, def_id ) ;
346+ return M :: find_foreign_static ( def_id , tcx, memory_extra ) ;
346347 }
347348 let instance = Instance :: mono ( tcx. tcx , def_id) ;
348349 let gid = GlobalId {
@@ -362,7 +363,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
362363 let allocation = tcx. alloc_map . lock ( ) . unwrap_memory ( raw_const. alloc_id ) ;
363364 // We got tcx memory. Let the machine figure out whether and how to
364365 // turn that into memory with the right pointer tag.
365- M :: adjust_static_allocation ( allocation)
366+ M :: adjust_static_allocation ( allocation, memory_extra )
366367 } )
367368 }
368369
@@ -372,7 +373,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
372373 // `get_static_alloc` that we can actually use directly without inserting anything anywhere.
373374 // So the error type is `EvalResult<'tcx, &Allocation<M::PointerTag>>`.
374375 let a = self . alloc_map . get_or ( id, || {
375- let alloc = Self :: get_static_alloc ( self . tcx , id ) . map_err ( Err ) ?;
376+ let alloc = Self :: get_static_alloc ( id , self . tcx , & self . extra ) . map_err ( Err ) ?;
376377 match alloc {
377378 Cow :: Borrowed ( alloc) => {
378379 // We got a ref, cheaply return that as an "error" so that the
@@ -401,10 +402,11 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
401402 id : AllocId ,
402403 ) -> EvalResult < ' tcx , & mut Allocation < M :: PointerTag , M :: AllocExtra > > {
403404 let tcx = self . tcx ;
405+ let memory_extra = & self . extra ;
404406 let a = self . alloc_map . get_mut_or ( id, || {
405407 // Need to make a copy, even if `get_static_alloc` is able
406408 // to give us a cheap reference.
407- let alloc = Self :: get_static_alloc ( tcx, id ) ?;
409+ let alloc = Self :: get_static_alloc ( id , tcx, memory_extra ) ?;
408410 if alloc. mutability == Mutability :: Immutable {
409411 return err ! ( ModifiedConstantMemory ) ;
410412 }
0 commit comments