about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/interpret
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2021-01-24 12:12:08 +0100
committerRalf Jung <post@ralfj.de>2021-01-30 12:29:57 +0100
commit944237f6cd2b7e732b6875bf0956bf323cc3316b (patch)
treebc1c64c18793c4bdce42bd022ca6026cb9e02b2a /compiler/rustc_mir/src/interpret
parent4d0dd02ee07bddad9136f95c9f7846ebf3eb3fc5 (diff)
downloadrust-944237f6cd2b7e732b6875bf0956bf323cc3316b.tar.gz
rust-944237f6cd2b7e732b6875bf0956bf323cc3316b.zip
codegen: assume constants cannot fail to evaluate
also don't submit code to LLVM when the session has errors
Diffstat (limited to 'compiler/rustc_mir/src/interpret')
-rw-r--r--compiler/rustc_mir/src/interpret/operand.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_mir/src/interpret/operand.rs b/compiler/rustc_mir/src/interpret/operand.rs
index d9437a312ae..88236458a21 100644
--- a/compiler/rustc_mir/src/interpret/operand.rs
+++ b/compiler/rustc_mir/src/interpret/operand.rs
@@ -511,6 +511,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
             Constant(ref constant) => {
                 let val =
                     self.subst_from_current_frame_and_normalize_erasing_regions(constant.literal);
+                // This can still fail:
+                // * During ConstProp, with `TooGeneric` or since the `requried_consts` were not all
+                //   checked yet.
+                // * During CTFE, since promoteds in `const`/`static` initializer bodies can fail.
                 self.const_to_op(val, layout)?
             }
         };