@@ -582,39 +582,37 @@ where
582582 ) -> EvalResult < ' tcx , MPlaceTy < ' tcx , M :: PointerTag > > {
583583 use rustc:: mir:: Place :: * ;
584584 use rustc:: mir:: PlaceBase ;
585+ use rustc:: mir:: Static ;
585586 Ok ( match * mir_place {
586- Base ( PlaceBase :: Static ( ref static_) ) => {
587- match static_. promoted {
588- Some ( promoted) => {
589- let instance = self . frame ( ) . instance ;
590- self . const_eval_raw ( GlobalId {
591- instance,
592- promoted : Some ( promoted) ,
593- } ) ?
594- }
595- None => {
596- assert ! ( !static_. ty. needs_subst( ) ) ;
597- let layout = self . layout_of ( static_. ty ) ?;
598- let instance = ty:: Instance :: mono ( * self . tcx , static_. def_id ) ;
599- let cid = GlobalId {
600- instance,
601- promoted : None
602- } ;
603- // Just create a lazy reference, so we can support recursive statics.
604- // tcx takes are of assigning every static one and only one unique AllocId.
605- // When the data here is ever actually used, memory will notice,
606- // and it knows how to deal with alloc_id that are present in the
607- // global table but not in its local memory: It calls back into tcx through
608- // a query, triggering the CTFE machinery to actually turn this lazy reference
609- // into a bunch of bytes. IOW, statics are evaluated with CTFE even when
610- // this EvalContext uses another Machine (e.g., in miri). This is what we
611- // want! This way, computing statics works concistently between codegen
612- // and miri: They use the same query to eventually obtain a `ty::Const`
613- // and use that for further computation.
614- let alloc = self . tcx . alloc_map . lock ( ) . intern_static ( cid. instance . def_id ( ) ) ;
615- MPlaceTy :: from_aligned_ptr ( Pointer :: from ( alloc) . with_default_tag ( ) , layout)
616- }
617- }
587+ Base ( PlaceBase :: Static ( box Static { promoted : Some ( promoted) , ty, ..} ) ) => {
588+ let instance = self . frame ( ) . instance ;
589+ self . const_eval_raw ( GlobalId {
590+ instance,
591+ promoted : Some ( promoted) ,
592+ } ) ?
593+ }
594+
595+ Base ( PlaceBase :: Static ( box Static { promoted : None , ty, def_id} ) ) => {
596+ assert ! ( !ty. needs_subst( ) ) ;
597+ let layout = self . layout_of ( ty) ?;
598+ let instance = ty:: Instance :: mono ( * self . tcx , def_id) ;
599+ let cid = GlobalId {
600+ instance,
601+ promoted : None
602+ } ;
603+ // Just create a lazy reference, so we can support recursive statics.
604+ // tcx takes are of assigning every static one and only one unique AllocId.
605+ // When the data here is ever actually used, memory will notice,
606+ // and it knows how to deal with alloc_id that are present in the
607+ // global table but not in its local memory: It calls back into tcx through
608+ // a query, triggering the CTFE machinery to actually turn this lazy reference
609+ // into a bunch of bytes. IOW, statics are evaluated with CTFE even when
610+ // this EvalContext uses another Machine (e.g., in miri). This is what we
611+ // want! This way, computing statics works concistently between codegen
612+ // and miri: They use the same query to eventually obtain a `ty::Const`
613+ // and use that for further computation.
614+ let alloc = self . tcx . alloc_map . lock ( ) . intern_static ( cid. instance . def_id ( ) ) ;
615+ MPlaceTy :: from_aligned_ptr ( Pointer :: from ( alloc) . with_default_tag ( ) , layout)
618616 }
619617
620618 _ => bug ! ( "eval_place_to_mplace called on {:?}" , mir_place) ,
0 commit comments