remove GlobalKind

This commit is contained in:
Oliver Schneider 2016-10-21 11:54:38 +02:00
parent e82e6132ec
commit 9d0b903d9d
No known key found for this signature in database
GPG Key ID: 56D6EEA0FC67AC46
2 changed files with 7 additions and 14 deletions

View File

@ -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<mir::Promoted>,
}
#[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)
}

View File

@ -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;