Add Debug impl and erase region for TypedConstVal

This commit is contained in:
Florian Hahn 2016-01-21 22:49:26 +01:00
parent d31027d3bf
commit 9884ff1dfb
2 changed files with 10 additions and 2 deletions

View File

@ -891,13 +891,20 @@ pub struct Constant<'tcx> {
pub literal: Literal<'tcx>,
}
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct TypedConstVal<'tcx> {
pub ty: Ty<'tcx>,
pub span: Span,
pub value: ConstVal
}
impl<'tcx> Debug for TypedConstVal<'tcx> {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
try!(write!(fmt, "const "));
fmt_const_val(fmt, &self.value)
}
}
#[derive(Clone, Copy, Debug, PartialEq, RustcEncodable, RustcDecodable)]
pub enum ItemKind {
Constant,

View File

@ -143,8 +143,9 @@ impl<'a, 'tcx> EraseRegions<'a, 'tcx> {
Rvalue::Use(ref mut operand) => {
self.erase_regions_operand(operand)
}
Rvalue::Repeat(ref mut operand, _) => {
Rvalue::Repeat(ref mut operand, ref mut value) => {
self.erase_regions_operand(operand);
value.ty = self.tcx.erase_regions(&value.ty);
}
Rvalue::Ref(ref mut region, _, ref mut lvalue) => {
*region = ty::ReStatic;