diff options
| author | Michael Goulet <michael@errs.io> | 2022-10-20 17:53:29 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-10-23 17:23:35 +0000 |
| commit | 6e6fe30d0f7e3dcbbf3988650311cee179992e5d (patch) | |
| tree | 31530f216f64efa6a19ad6352d432430ed2e2216 /compiler/rustc_const_eval/src/interpret | |
| parent | dd51b36fb261513a0886d98c16be7fcc43c66272 (diff) | |
| download | rust-6e6fe30d0f7e3dcbbf3988650311cee179992e5d.tar.gz rust-6e6fe30d0f7e3dcbbf3988650311cee179992e5d.zip | |
Comment why normalization is needed for debug assertions
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/operand.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index 719588a936c..0c212cf59e1 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -554,6 +554,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { val: &mir::ConstantKind<'tcx>, layout: Option<TyAndLayout<'tcx>>, ) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> { + // FIXME(const_prop): normalization needed b/c const prop lint in + // `mir_drops_elaborated_and_const_checked`, which happens before + // optimized MIR. Only after optimizing the MIR can we guarantee + // that the `RevealAll` pass has happened and that the body's consts + // are normalized, so any call to resolve before that needs to be + // manually normalized. + let val = self.tcx.normalize_erasing_regions(self.param_env, *val); match val { mir::ConstantKind::Ty(ct) => { match ct.kind() { @@ -585,7 +592,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } } } - mir::ConstantKind::Val(val, ty) => self.const_val_to_op(*val, *ty, layout), + mir::ConstantKind::Val(val, ty) => self.const_val_to_op(val, ty, layout), mir::ConstantKind::Unevaluated(uv, _) => { let instance = self.resolve(uv.def, uv.substs)?; Ok(self.eval_to_allocation(GlobalId { instance, promoted: uv.promoted })?.into()) |
