Skip to content

Commit 9b71592

Browse files
committed
Normalize constants before evaluating them.
1 parent 1e739d7 commit 9b71592

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

compiler/rustc_mir_transform/src/const_prop.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,9 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
454454

455455
/// Returns the value, if any, of evaluating `c`.
456456
fn eval_constant(&mut self, c: &Constant<'tcx>) -> Option<OpTy<'tcx>> {
457-
// FIXME we need to revisit this for #67176
458-
if c.needs_subst() {
459-
return None;
460-
}
461-
462457
// No span, we don't want errors to be shown.
463-
self.ecx.eval_mir_constant(&c.literal, None, None).ok()
458+
let lit = self.tcx.try_normalize_erasing_regions(self.param_env, c.literal).ok()?;
459+
self.ecx.eval_mir_constant(&lit, None, None).ok()
464460
}
465461

466462
/// Returns the value, if any, of evaluating `place`.
@@ -550,10 +546,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
550546
| Rvalue::CheckedBinaryOp(..) => {}
551547
}
552548

553-
// FIXME we need to revisit this for #67176
554-
if rvalue.needs_subst() {
555-
return None;
556-
}
557549
if !rvalue
558550
.ty(&self.ecx.frame().body.local_decls, *self.ecx.tcx)
559551
.is_sized(*self.ecx.tcx, self.param_env)

0 commit comments

Comments
 (0)