treat all mir::Constant values as ConstantKind::Val

This commit is contained in:
b-naber 2022-02-16 10:54:36 +01:00
parent 6045c34f15
commit 40e4bd2d02
6 changed files with 56 additions and 10 deletions

View file

@ -334,6 +334,21 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
&mut self,
constant: mir::ConstantKind<'tcx>,
) -> Result<mir::ConstantKind<'tcx>, Self::Error> {
constant.try_super_fold_with(self)
let constant_kind = match constant {
mir::ConstantKind::Ty(c) => {
let const_folded = c.try_super_fold_with(self)?;
match const_folded.val() {
ty::ConstKind::Value(cv) => {
// FIXME With Valtrees we need to convert `cv: ValTree`
// to a `ConstValue` here.
mir::ConstantKind::Val(cv, const_folded.ty())
}
_ => mir::ConstantKind::Ty(const_folded),
}
}
mir::ConstantKind::Val(_, _) => constant.try_super_fold_with(self)?,
};
Ok(constant_kind)
}
}