From 9d0b903d9db7baa07c3b1bac274e1b071005f44d Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 21 Oct 2016 11:54:38 +0200 Subject: [PATCH] remove GlobalKind --- src/interpreter/mod.rs | 16 +++++----------- src/interpreter/step.rs | 5 ++--- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/interpreter/mod.rs b/src/interpreter/mod.rs index 66053e9dd59..1cbfafd10b2 100644 --- a/src/interpreter/mod.rs +++ b/src/interpreter/mod.rs @@ -141,14 +141,8 @@ pub struct GlobalId<'tcx> { /// but that would only require more branching when working with constants, and not bring any /// real benefits. substs: &'tcx Substs<'tcx>, - kind: GlobalKind, -} - -#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] -enum GlobalKind { - Promoted(mir::Promoted), - /// Statics, constants and associated constants - Global, + /// this `Option` is `Some` for promoted constants + promoted: Option, } #[derive(Copy, Clone, Debug)] @@ -845,7 +839,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { let cid = GlobalId { def_id: def_id, substs: substs, - kind: GlobalKind::Global, + promoted: None, }; self.read_lvalue(Lvalue::Global(cid))? } @@ -855,7 +849,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { let cid = GlobalId { def_id: self.frame().def_id, substs: self.substs(), - kind: GlobalKind::Promoted(index), + promoted: Some(index), }; self.read_lvalue(Lvalue::Global(cid))? } @@ -915,7 +909,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { let cid = GlobalId { def_id: def_id, substs: substs, - kind: GlobalKind::Global, + promoted: None, }; Lvalue::Global(cid) } diff --git a/src/interpreter/step.rs b/src/interpreter/step.rs index e745fe64d71..eac5494f431 100644 --- a/src/interpreter/step.rs +++ b/src/interpreter/step.rs @@ -7,7 +7,6 @@ use super::{ GlobalId, EvalContext, Lvalue, - GlobalKind, StackPopCleanup, Global, }; @@ -122,7 +121,7 @@ impl<'a, 'b, 'tcx> ConstantExtractor<'a, 'b, 'tcx> { let cid = GlobalId { def_id: def_id, substs: substs, - kind: GlobalKind::Global, + promoted: None, }; if self.ecx.globals.contains_key(&cid) { return; @@ -170,7 +169,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for ConstantExtractor<'a, 'b, 'tcx> { let cid = GlobalId { def_id: self.def_id, substs: self.substs, - kind: GlobalKind::Promoted(index), + promoted: Some(index), }; if self.ecx.globals.contains_key(&cid) { return;