diff options
| author | Ralf Jung <post@ralfj.de> | 2021-01-24 12:12:08 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2021-01-30 12:29:57 +0100 |
| commit | 944237f6cd2b7e732b6875bf0956bf323cc3316b (patch) | |
| tree | bc1c64c18793c4bdce42bd022ca6026cb9e02b2a /compiler/rustc_mir/src/interpret | |
| parent | 4d0dd02ee07bddad9136f95c9f7846ebf3eb3fc5 (diff) | |
| download | rust-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.rs | 4 |
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)? } }; |
