diff options
| author | Ralf Jung <post@ralfj.de> | 2023-10-06 18:25:23 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-10-06 18:25:23 +0200 |
| commit | fa248cd9e6927dd6981078963aa47feb941a0d10 (patch) | |
| tree | 0bb023a0045a8ceffd27e8a71f34537d998b0c97 /compiler/rustc_codegen_ssa/src | |
| parent | acb7c21507f4c6f7247e702287ab4caf64b31235 (diff) | |
| download | rust-fa248cd9e6927dd6981078963aa47feb941a0d10.tar.gz rust-fa248cd9e6927dd6981078963aa47feb941a0d10.zip | |
add some comments explaining how the required_consts stuff fits together
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/constant.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/mod.rs | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/constant.rs b/compiler/rustc_codegen_ssa/src/mir/constant.rs index fde4e85f966..558f64fffc2 100644 --- a/compiler/rustc_codegen_ssa/src/mir/constant.rs +++ b/compiler/rustc_codegen_ssa/src/mir/constant.rs @@ -21,6 +21,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } pub fn eval_mir_constant(&self, constant: &mir::ConstOperand<'tcx>) -> mir::ConstValue<'tcx> { + // `MirUsedCollector` visited all constants before codegen began, so if we got here there + // can be no more constants that fail to evaluate. self.monomorphize(constant.const_) .eval(self.cx.tcx(), ty::ParamEnv::reveal_all(), Some(constant.span)) .expect("erroneous constant not captured by required_consts") diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs index 06cdc47610d..d0b799e087b 100644 --- a/compiler/rustc_codegen_ssa/src/mir/mod.rs +++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs @@ -209,6 +209,10 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( caller_location: None, }; + // It may seem like we should iterate over `required_consts` to ensure they all successfully + // evaluate; however, the `MirUsedCollector` already did that during the collection phase of + // monomorphization so we don't have to do it again. + fx.per_local_var_debug_info = fx.compute_per_local_var_debug_info(&mut start_bx); let memory_locals = analyze::non_ssa_locals(&fx); |
