Also reveal constants before MIR opts.

This commit is contained in:
Camille GILLOT 2023-04-14 18:59:17 +00:00
parent 21fab435da
commit 7efcf67a3b

View File

@ -34,11 +34,23 @@ impl<'tcx> MutVisitor<'tcx> for RevealAllVisitor<'tcx> {
self.tcx
}
#[inline]
fn visit_constant(&mut self, constant: &mut Constant<'tcx>, _: Location) {
// We have to use `try_normalize_erasing_regions` here, since it's
// possible that we visit impossible-to-satisfy where clauses here,
// see #91745
if let Ok(c) = self.tcx.try_normalize_erasing_regions(self.param_env, constant.literal) {
constant.literal = c;
}
}
#[inline]
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, _: TyContext) {
// We have to use `try_normalize_erasing_regions` here, since it's
// possible that we visit impossible-to-satisfy where clauses here,
// see #91745
*ty = self.tcx.try_normalize_erasing_regions(self.param_env, *ty).unwrap_or(*ty);
if let Ok(t) = self.tcx.try_normalize_erasing_regions(self.param_env, *ty) {
*ty = t;
}
}
}