Skip to content

Commit 24dbf9c

Browse files
committed
Only assign value in remove_const.
1 parent 081bc75 commit 24dbf9c

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

compiler/rustc_mir_transform/src/const_prop.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//! Propagates constants for early reporting of statically known
22
//! assertion failures
33
4-
use std::cell::Cell;
5-
64
use either::Right;
75

86
use rustc_const_eval::const_eval::CheckAlignment;
@@ -25,8 +23,8 @@ use rustc_trait_selection::traits;
2523
use crate::MirPass;
2624
use rustc_const_eval::interpret::{
2725
self, compile_time_machine, AllocId, ConstAllocation, ConstValue, CtfeValidationMode, Frame,
28-
ImmTy, Immediate, InterpCx, InterpResult, LocalState, LocalValue, MemoryKind, OpTy, PlaceTy,
29-
Pointer, Scalar, StackPopCleanup, StackPopUnwind,
26+
ImmTy, Immediate, InterpCx, InterpResult, LocalValue, MemoryKind, OpTy, PlaceTy, Pointer,
27+
Scalar, StackPopCleanup, StackPopUnwind,
3028
};
3129

3230
/// The maximum number of bytes that we'll allocate space for a local or the return value.
@@ -437,10 +435,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
437435
/// Remove `local` from the pool of `Locals`. Allows writing to them,
438436
/// but not reading from them anymore.
439437
fn remove_const(ecx: &mut InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>, local: Local) {
440-
ecx.frame_mut().locals[local] = LocalState {
441-
value: LocalValue::Live(interpret::Operand::Immediate(interpret::Immediate::Uninit)),
442-
layout: Cell::new(None),
443-
};
438+
ecx.frame_mut().locals[local].value =
439+
LocalValue::Live(interpret::Operand::Immediate(interpret::Immediate::Uninit));
444440
}
445441

446442
/// Returns the value, if any, of evaluating `c`.

compiler/rustc_mir_transform/src/const_prop_lint.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
//! Propagates constants for early reporting of statically known
22
//! assertion failures
33
4-
use std::cell::Cell;
5-
64
use either::{Left, Right};
75

86
use rustc_const_eval::interpret::Immediate;
97
use rustc_const_eval::interpret::{
10-
self, InterpCx, InterpResult, LocalState, LocalValue, MemoryKind, OpTy, Scalar, StackPopCleanup,
8+
self, InterpCx, InterpResult, LocalValue, MemoryKind, OpTy, Scalar, StackPopCleanup,
119
};
1210
use rustc_hir::def::DefKind;
1311
use rustc_hir::HirId;
@@ -254,10 +252,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
254252
/// Remove `local` from the pool of `Locals`. Allows writing to them,
255253
/// but not reading from them anymore.
256254
fn remove_const(ecx: &mut InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>, local: Local) {
257-
ecx.frame_mut().locals[local] = LocalState {
258-
value: LocalValue::Live(interpret::Operand::Immediate(interpret::Immediate::Uninit)),
259-
layout: Cell::new(None),
260-
};
255+
ecx.frame_mut().locals[local].value =
256+
LocalValue::Live(interpret::Operand::Immediate(interpret::Immediate::Uninit));
261257
}
262258

263259
fn lint_root(&self, source_info: SourceInfo) -> Option<HirId> {

0 commit comments

Comments
 (0)