@@ -596,38 +596,32 @@ where
596596 & self ,
597597 place_static : & mir:: Static < ' tcx >
598598 ) -> InterpResult < ' tcx , MPlaceTy < ' tcx , M :: PointerTag > > {
599- use rustc:: mir:: StaticKind ;
600-
601- Ok ( match place_static. kind {
602- StaticKind :: Static => {
603- let ty = place_static. ty ;
604- assert ! ( !ty. needs_subst( ) ) ;
605- let layout = self . layout_of ( ty) ?;
606- let instance = ty:: Instance :: mono ( * self . tcx , place_static. def_id ) ;
607- let cid = GlobalId {
608- instance,
609- promoted : None
610- } ;
611- // Just create a lazy reference, so we can support recursive statics.
612- // tcx takes care of assigning every static one and only one unique AllocId.
613- // When the data here is ever actually used, memory will notice,
614- // and it knows how to deal with alloc_id that are present in the
615- // global table but not in its local memory: It calls back into tcx through
616- // a query, triggering the CTFE machinery to actually turn this lazy reference
617- // into a bunch of bytes. IOW, statics are evaluated with CTFE even when
618- // this InterpCx uses another Machine (e.g., in miri). This is what we
619- // want! This way, computing statics works consistently between codegen
620- // and miri: They use the same query to eventually obtain a `ty::Const`
621- // and use that for further computation.
622- //
623- // Notice that statics have *two* AllocIds: the lazy one, and the resolved
624- // one. Here we make sure that the interpreted program never sees the
625- // resolved ID. Also see the doc comment of `Memory::get_static_alloc`.
626- let alloc_id = self . tcx . alloc_map . lock ( ) . create_static_alloc ( cid. instance . def_id ( ) ) ;
627- let ptr = self . tag_static_base_pointer ( Pointer :: from ( alloc_id) ) ;
628- MPlaceTy :: from_aligned_ptr ( ptr, layout)
629- }
630- } )
599+ let ty = place_static. ty ;
600+ assert ! ( !ty. needs_subst( ) ) ;
601+ let layout = self . layout_of ( ty) ?;
602+ let instance = ty:: Instance :: mono ( * self . tcx , place_static. def_id ) ;
603+ let cid = GlobalId {
604+ instance,
605+ promoted : None
606+ } ;
607+ // Just create a lazy reference, so we can support recursive statics.
608+ // tcx takes care of assigning every static one and only one unique AllocId.
609+ // When the data here is ever actually used, memory will notice,
610+ // and it knows how to deal with alloc_id that are present in the
611+ // global table but not in its local memory: It calls back into tcx through
612+ // a query, triggering the CTFE machinery to actually turn this lazy reference
613+ // into a bunch of bytes. IOW, statics are evaluated with CTFE even when
614+ // this InterpCx uses another Machine (e.g., in miri). This is what we
615+ // want! This way, computing statics works consistently between codegen
616+ // and miri: They use the same query to eventually obtain a `ty::Const`
617+ // and use that for further computation.
618+ //
619+ // Notice that statics have *two* AllocIds: the lazy one, and the resolved
620+ // one. Here we make sure that the interpreted program never sees the
621+ // resolved ID. Also see the doc comment of `Memory::get_static_alloc`.
622+ let alloc_id = self . tcx . alloc_map . lock ( ) . create_static_alloc ( cid. instance . def_id ( ) ) ;
623+ let ptr = self . tag_static_base_pointer ( Pointer :: from ( alloc_id) ) ;
624+ Ok ( MPlaceTy :: from_aligned_ptr ( ptr, layout) )
631625 }
632626
633627 /// Computes a place. You should only use this if you intend to write into this
0 commit comments