Skip to content

Commit 6a8fcdc

Browse files
committed
Don't validate constants before propagation
Validation is neither necessary nor desirable. The validation is already omitted at mir-opt-level >= 3, so there there are not changes in MIR test output (the propagation of invalid constants is covered by an existing test in tests/mir-opt/const_prop/invalid_constant.rs).
1 parent 9c044d7 commit 6a8fcdc

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

compiler/rustc_mir_transform/src/const_prop.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ use rustc_trait_selection::traits;
2222

2323
use crate::MirPass;
2424
use rustc_const_eval::interpret::{
25-
self, compile_time_machine, AllocId, ConstAllocation, ConstValue, CtfeValidationMode, Frame,
26-
ImmTy, Immediate, InterpCx, InterpResult, LocalValue, MemoryKind, OpTy, PlaceTy, Pointer,
27-
Scalar, StackPopCleanup,
25+
self, compile_time_machine, AllocId, ConstAllocation, ConstValue, Frame, ImmTy, Immediate,
26+
InterpCx, InterpResult, LocalValue, MemoryKind, OpTy, PlaceTy, Pointer, Scalar,
27+
StackPopCleanup,
2828
};
2929

3030
/// The maximum number of bytes that we'll allocate space for a local or the return value.
@@ -628,18 +628,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
628628
}
629629

630630
trace!("attempting to replace {:?} with {:?}", rval, value);
631-
if let Err(e) = self.ecx.const_validate_operand(
632-
value,
633-
vec![],
634-
// FIXME: is ref tracking too expensive?
635-
// FIXME: what is the point of ref tracking if we do not even check the tracked refs?
636-
&mut interpret::RefTracking::empty(),
637-
CtfeValidationMode::Regular,
638-
) {
639-
trace!("validation error, attempt failed: {:?}", e);
640-
return;
641-
}
642-
643631
// FIXME> figure out what to do when read_immediate_raw fails
644632
let imm = self.ecx.read_immediate_raw(value).ok();
645633

0 commit comments

Comments
 (0)