Skip to content

Commit 7efcf67

Browse files
committed
Also reveal constants before MIR opts.
1 parent 21fab43 commit 7efcf67

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

compiler/rustc_mir_transform/src/reveal_all.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,23 @@ impl<'tcx> MutVisitor<'tcx> for RevealAllVisitor<'tcx> {
3434
self.tcx
3535
}
3636

37+
#[inline]
38+
fn visit_constant(&mut self, constant: &mut Constant<'tcx>, _: Location) {
39+
// We have to use `try_normalize_erasing_regions` here, since it's
40+
// possible that we visit impossible-to-satisfy where clauses here,
41+
// see #91745
42+
if let Ok(c) = self.tcx.try_normalize_erasing_regions(self.param_env, constant.literal) {
43+
constant.literal = c;
44+
}
45+
}
46+
3747
#[inline]
3848
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, _: TyContext) {
3949
// We have to use `try_normalize_erasing_regions` here, since it's
4050
// possible that we visit impossible-to-satisfy where clauses here,
4151
// see #91745
42-
*ty = self.tcx.try_normalize_erasing_regions(self.param_env, *ty).unwrap_or(*ty);
52+
if let Ok(t) = self.tcx.try_normalize_erasing_regions(self.param_env, *ty) {
53+
*ty = t;
54+
}
4355
}
4456
}

0 commit comments

Comments
 (0)