@@ -625,33 +625,27 @@ where
625625 & self ,
626626 place_static : & mir:: Static < ' tcx > ,
627627 ) -> InterpResult < ' tcx , MPlaceTy < ' tcx , M :: PointerTag > > {
628- use rustc:: mir:: StaticKind ;
629-
630- Ok ( match place_static. kind {
631- StaticKind :: Static => {
632- let ty = place_static. ty ;
633- assert ! ( !ty. needs_subst( ) ) ;
634- let layout = self . layout_of ( ty) ?;
635- // Just create a lazy reference, so we can support recursive statics.
636- // tcx takes care of assigning every static one and only one unique AllocId.
637- // When the data here is ever actually used, memory will notice,
638- // and it knows how to deal with alloc_id that are present in the
639- // global table but not in its local memory: It calls back into tcx through
640- // a query, triggering the CTFE machinery to actually turn this lazy reference
641- // into a bunch of bytes. IOW, statics are evaluated with CTFE even when
642- // this InterpCx uses another Machine (e.g., in miri). This is what we
643- // want! This way, computing statics works consistently between codegen
644- // and miri: They use the same query to eventually obtain a `ty::Const`
645- // and use that for further computation.
646- //
647- // Notice that statics have *two* AllocIds: the lazy one, and the resolved
648- // one. Here we make sure that the interpreted program never sees the
649- // resolved ID. Also see the doc comment of `Memory::get_static_alloc`.
650- let alloc_id = self . tcx . alloc_map . lock ( ) . create_static_alloc ( place_static. def_id ) ;
651- let ptr = self . tag_static_base_pointer ( Pointer :: from ( alloc_id) ) ;
652- MPlaceTy :: from_aligned_ptr ( ptr, layout)
653- }
654- } )
628+ let ty = place_static. ty ;
629+ assert ! ( !ty. needs_subst( ) ) ;
630+ let layout = self . layout_of ( ty) ?;
631+ // Just create a lazy reference, so we can support recursive statics.
632+ // tcx takes care of assigning every static one and only one unique AllocId.
633+ // When the data here is ever actually used, memory will notice,
634+ // and it knows how to deal with alloc_id that are present in the
635+ // global table but not in its local memory: It calls back into tcx through
636+ // a query, triggering the CTFE machinery to actually turn this lazy reference
637+ // into a bunch of bytes. IOW, statics are evaluated with CTFE even when
638+ // this InterpCx uses another Machine (e.g., in miri). This is what we
639+ // want! This way, computing statics works consistently between codegen
640+ // and miri: They use the same query to eventually obtain a `ty::Const`
641+ // and use that for further computation.
642+ //
643+ // Notice that statics have *two* AllocIds: the lazy one, and the resolved
644+ // one. Here we make sure that the interpreted program never sees the
645+ // resolved ID. Also see the doc comment of `Memory::get_static_alloc`.
646+ let alloc_id = self . tcx . alloc_map . lock ( ) . create_static_alloc ( place_static. def_id ) ;
647+ let ptr = self . tag_static_base_pointer ( Pointer :: from ( alloc_id) ) ;
648+ Ok ( MPlaceTy :: from_aligned_ptr ( ptr, layout) )
655649 }
656650
657651 /// Computes a place. You should only use this if you intend to write into this
0 commit comments