@@ -76,7 +76,7 @@ pub struct Frame<'mir, 'tcx: 'mir, Tag=(), Extra=()> {
7676 /// The locals are stored as `Option<Value>`s.
7777 /// `None` represents a local that is currently dead, while a live local
7878 /// can either directly contain `Scalar` or refer to some part of an `Allocation`.
79- pub locals : IndexVec < mir:: Local , LocalValue < ' tcx , Tag > > ,
79+ pub locals : IndexVec < mir:: Local , LocalState < ' tcx , Tag > > ,
8080
8181 ////////////////////////////////////////////////////////////////////////////////
8282 // Current position within the function
@@ -107,15 +107,15 @@ pub enum StackPopCleanup {
107107
108108/// State of a local variable including a memoized layout
109109#[ derive( Clone , PartialEq , Eq ) ]
110- pub struct LocalValue < ' tcx , Tag =( ) , Id =AllocId > {
111- pub state : LocalState < Tag , Id > ,
110+ pub struct LocalState < ' tcx , Tag =( ) , Id =AllocId > {
111+ pub state : LocalValue < Tag , Id > ,
112112 /// Don't modify if `Some`, this is only used to prevent computing the layout twice
113113 pub layout : Cell < Option < TyLayout < ' tcx > > > ,
114114}
115115
116116/// State of a local variable
117117#[ derive( Copy , Clone , PartialEq , Eq , Hash ) ]
118- pub enum LocalState < Tag =( ) , Id =AllocId > {
118+ pub enum LocalValue < Tag =( ) , Id =AllocId > {
119119 Dead ,
120120 // Mostly for convenience, we re-use the `Operand` type here.
121121 // This is an optimization over just always having a pointer here;
@@ -124,18 +124,18 @@ pub enum LocalState<Tag=(), Id=AllocId> {
124124 Live ( Operand < Tag , Id > ) ,
125125}
126126
127- impl < ' tcx , Tag > LocalValue < ' tcx , Tag > {
127+ impl < ' tcx , Tag > LocalState < ' tcx , Tag > {
128128 pub fn access ( & self ) -> EvalResult < ' tcx , & Operand < Tag > > {
129129 match self . state {
130- LocalState :: Dead => err ! ( DeadLocal ) ,
131- LocalState :: Live ( ref val) => Ok ( val) ,
130+ LocalValue :: Dead => err ! ( DeadLocal ) ,
131+ LocalValue :: Live ( ref val) => Ok ( val) ,
132132 }
133133 }
134134
135135 pub fn access_mut ( & mut self ) -> EvalResult < ' tcx , & mut Operand < Tag > > {
136136 match self . state {
137- LocalState :: Dead => err ! ( DeadLocal ) ,
138- LocalState :: Live ( ref mut val) => Ok ( val) ,
137+ LocalValue :: Dead => err ! ( DeadLocal ) ,
138+ LocalValue :: Live ( ref mut val) => Ok ( val) ,
139139 }
140140 }
141141}
@@ -474,18 +474,18 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
474474 // don't allocate at all for trivial constants
475475 if mir. local_decls . len ( ) > 1 {
476476 // We put some marker immediate into the locals that we later want to initialize.
477- // This can be anything except for LocalState ::Dead -- because *that* is the
477+ // This can be anything except for LocalValue ::Dead -- because *that* is the
478478 // value we use for things that we know are initially dead.
479- let dummy = LocalValue {
480- state : LocalState :: Live ( Operand :: Immediate ( Immediate :: Scalar (
479+ let dummy = LocalState {
480+ state : LocalValue :: Live ( Operand :: Immediate ( Immediate :: Scalar (
481481 ScalarMaybeUndef :: Undef ,
482482 ) ) ) ,
483483 layout : Cell :: new ( None ) ,
484484 } ;
485485 let mut locals = IndexVec :: from_elem ( dummy, & mir. local_decls ) ;
486486 // Return place is handled specially by the `eval_place` functions, and the
487487 // entry in `locals` should never be used. Make it dead, to be sure.
488- locals[ mir:: RETURN_PLACE ] . state = LocalState :: Dead ;
488+ locals[ mir:: RETURN_PLACE ] . state = LocalValue :: Dead ;
489489 // Now mark those locals as dead that we do not want to initialize
490490 match self . tcx . describe_def ( instance. def_id ( ) ) {
491491 // statics and constants don't have `Storage*` statements, no need to look for them
@@ -498,7 +498,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
498498 match stmt. kind {
499499 StorageLive ( local) |
500500 StorageDead ( local) => {
501- locals[ local] . state = LocalState :: Dead ;
501+ locals[ local] . state = LocalValue :: Dead ;
502502 }
503503 _ => { }
504504 }
@@ -509,14 +509,14 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
509509 // Finally, properly initialize all those that still have the dummy value
510510 for ( idx, local) in locals. iter_enumerated_mut ( ) {
511511 match local. state {
512- LocalState :: Live ( _) => {
512+ LocalValue :: Live ( _) => {
513513 // This needs to be properly initialized.
514514 let ty = self . monomorphize ( mir. local_decls [ idx] . ty ) ?;
515515 let layout = self . layout_of ( ty) ?;
516- local. state = LocalState :: Live ( self . uninit_operand ( layout) ?) ;
516+ local. state = LocalValue :: Live ( self . uninit_operand ( layout) ?) ;
517517 local. layout = Cell :: new ( Some ( layout) ) ;
518518 }
519- LocalState :: Dead => {
519+ LocalValue :: Dead => {
520520 // Nothing to do
521521 }
522522 }
@@ -603,31 +603,31 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
603603 pub fn storage_live (
604604 & mut self ,
605605 local : mir:: Local
606- ) -> EvalResult < ' tcx , LocalState < M :: PointerTag > > {
606+ ) -> EvalResult < ' tcx , LocalValue < M :: PointerTag > > {
607607 assert ! ( local != mir:: RETURN_PLACE , "Cannot make return place live" ) ;
608608 trace ! ( "{:?} is now live" , local) ;
609609
610610 let layout = self . layout_of_local ( self . frame ( ) , local, None ) ?;
611- let init = LocalState :: Live ( self . uninit_operand ( layout) ?) ;
611+ let init = LocalValue :: Live ( self . uninit_operand ( layout) ?) ;
612612 // StorageLive *always* kills the value that's currently stored
613613 Ok ( mem:: replace ( & mut self . frame_mut ( ) . locals [ local] . state , init) )
614614 }
615615
616616 /// Returns the old value of the local.
617617 /// Remember to deallocate that!
618- pub fn storage_dead ( & mut self , local : mir:: Local ) -> LocalState < M :: PointerTag > {
618+ pub fn storage_dead ( & mut self , local : mir:: Local ) -> LocalValue < M :: PointerTag > {
619619 assert ! ( local != mir:: RETURN_PLACE , "Cannot make return place dead" ) ;
620620 trace ! ( "{:?} is now dead" , local) ;
621621
622- mem:: replace ( & mut self . frame_mut ( ) . locals [ local] . state , LocalState :: Dead )
622+ mem:: replace ( & mut self . frame_mut ( ) . locals [ local] . state , LocalValue :: Dead )
623623 }
624624
625625 pub ( super ) fn deallocate_local (
626626 & mut self ,
627- local : LocalState < M :: PointerTag > ,
627+ local : LocalValue < M :: PointerTag > ,
628628 ) -> EvalResult < ' tcx > {
629629 // FIXME: should we tell the user that there was a local which was never written to?
630- if let LocalState :: Live ( Operand :: Indirect ( MemPlace { ptr, .. } ) ) = local {
630+ if let LocalValue :: Live ( Operand :: Indirect ( MemPlace { ptr, .. } ) ) = local {
631631 trace ! ( "deallocating local" ) ;
632632 let ptr = ptr. to_ptr ( ) ?;
633633 self . memory . dump_alloc ( ptr. alloc_id ) ;
0 commit comments