Skip to content

Commit 765fa81

Browse files
committed
Swap the names of LocalValue and LocalState
1 parent a7a5cb6 commit 765fa81

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

src/librustc/mir/interpret/value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct RawConst<'tcx> {
1414
}
1515

1616
/// Represents a constant value in Rust. Scalar and ScalarPair are optimizations which
17-
/// matches the LocalValue optimizations for easy conversions between Value and ConstValue.
17+
/// matches the LocalState optimizations for easy conversions between Value and ConstValue.
1818
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Hash)]
1919
pub enum ConstValue<'tcx> {
2020
/// Used only for types with layout::abi::Scalar ABI and ZSTs

src/librustc_mir/interpret/eval_context.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

src/librustc_mir/interpret/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mod visitor;
1818
pub use rustc::mir::interpret::*; // have all the `interpret` symbols in one place: here
1919

2020
pub use self::eval_context::{
21-
EvalContext, Frame, StackPopCleanup, LocalValue, LocalState,
21+
EvalContext, Frame, StackPopCleanup, LocalState, LocalValue,
2222
};
2323

2424
pub use self::place::{Place, PlaceTy, MemPlace, MPlaceTy};

src/librustc_mir/interpret/snapshot.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2323
use syntax::ast::Mutability;
2424
use syntax::source_map::Span;
2525

26-
use super::eval_context::{LocalValue, StackPopCleanup};
27-
use super::{Frame, Memory, Operand, MemPlace, Place, Immediate, ScalarMaybeUndef, LocalState};
26+
use super::eval_context::{LocalState, StackPopCleanup};
27+
use super::{Frame, Memory, Operand, MemPlace, Place, Immediate, ScalarMaybeUndef, LocalValue};
2828
use const_eval::CompileTimeInterpreter;
2929

3030
#[derive(Default)]
@@ -250,11 +250,11 @@ impl_snapshot_for!(enum Operand {
250250
Indirect(m),
251251
});
252252

253-
impl_stable_hash_for!(enum ::interpret::LocalState {
253+
impl_stable_hash_for!(enum ::interpret::LocalValue {
254254
Dead,
255255
Live(x),
256256
});
257-
impl_snapshot_for!(enum LocalState {
257+
impl_snapshot_for!(enum LocalValue {
258258
Live(v),
259259
Dead,
260260
});
@@ -309,7 +309,7 @@ struct FrameSnapshot<'a, 'tcx: 'a> {
309309
span: &'a Span,
310310
return_to_block: &'a StackPopCleanup,
311311
return_place: Option<Place<(), AllocIdSnapshot<'a>>>,
312-
locals: IndexVec<mir::Local, LocalState<(), AllocIdSnapshot<'a>>>,
312+
locals: IndexVec<mir::Local, LocalValue<(), AllocIdSnapshot<'a>>>,
313313
block: &'a mir::BasicBlock,
314314
stmt: usize,
315315
}
@@ -356,17 +356,17 @@ impl<'a, 'mir, 'tcx, Ctx> Snapshot<'a, Ctx> for &'a Frame<'mir, 'tcx>
356356
}
357357
}
358358

359-
impl<'a, 'tcx, Ctx> Snapshot<'a, Ctx> for &'a LocalValue<'tcx>
359+
impl<'a, 'tcx, Ctx> Snapshot<'a, Ctx> for &'a LocalState<'tcx>
360360
where Ctx: SnapshotContext<'a>,
361361
{
362-
type Item = LocalState<(), AllocIdSnapshot<'a>>;
362+
type Item = LocalValue<(), AllocIdSnapshot<'a>>;
363363

364364
fn snapshot(&self, ctx: &'a Ctx) -> Self::Item {
365365
self.state.snapshot(ctx)
366366
}
367367
}
368368

369-
impl_stable_hash_for!(struct LocalValue<'tcx> {
369+
impl_stable_hash_for!(struct LocalState<'tcx> {
370370
state,
371371
layout -> _,
372372
});

0 commit comments

Comments
 (0)