Add a new normalization query just for mir constants

This commit is contained in:
Oli Scherer 2021-03-30 14:26:40 +00:00
parent c7c39ce6d0
commit dbacfbc368
19 changed files with 128 additions and 34 deletions

View file

@ -2410,7 +2410,8 @@ pub struct Constant<'tcx> {
pub literal: ConstantKind<'tcx>,
}
#[derive(Clone, Copy, PartialEq, PartialOrd, TyEncodable, TyDecodable, Hash, HashStable, Debug)]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, TyEncodable, TyDecodable, Hash, HashStable, Debug)]
#[derive(Lift)]
pub enum ConstantKind<'tcx> {
/// This constant came from the type system
Ty(&'tcx ty::Const<'tcx>),
@ -2709,7 +2710,13 @@ impl<'tcx> Display for Constant<'tcx> {
ty::FnDef(..) => {}
_ => write!(fmt, "const ")?,
}
match self.literal {
Display::fmt(&self.literal, fmt)
}
}
impl<'tcx> Display for ConstantKind<'tcx> {
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
match *self {
ConstantKind::Ty(c) => pretty_print_const(c, fmt, true),
ConstantKind::Val(val, ty) => pretty_print_const_value(val, ty, fmt, true),
}