about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorAlona Enraght-Moony <code@alona.page>2023-11-28 21:43:23 +0000
committerAlona Enraght-Moony <code@alona.page>2023-11-28 22:15:11 +0000
commit9121a41450e905fe5a12c11c955acc14ab1f92fe (patch)
treeb5a573a6a530526f56eefab7d68253c44109105e /compiler
parentb1a6cf4a0e7d6727516e943d86fdab8587b94722 (diff)
downloadrust-9121a41450e905fe5a12c11c955acc14ab1f92fe.tar.gz
rust-9121a41450e905fe5a12c11c955acc14ab1f92fe.zip
ConstProp: Remove const when rvalue check fails.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_mir_transform/src/const_prop.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_mir_transform/src/const_prop.rs b/compiler/rustc_mir_transform/src/const_prop.rs
index 9a16003bdc9..b96125de95e 100644
--- a/compiler/rustc_mir_transform/src/const_prop.rs
+++ b/compiler/rustc_mir_transform/src/const_prop.rs
@@ -439,6 +439,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
 
         // FIXME we need to revisit this for #67176
         if rvalue.has_param() {
+            trace!("skipping, has param");
             return None;
         }
         if !rvalue
@@ -707,7 +708,11 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
     fn visit_assign(&mut self, place: &Place<'tcx>, rvalue: &Rvalue<'tcx>, location: Location) {
         self.super_assign(place, rvalue, location);
 
-        let Some(()) = self.check_rvalue(rvalue) else { return };
+        let Some(()) = self.check_rvalue(rvalue) else {
+            trace!("rvalue check failed, removing const");
+            Self::remove_const(&mut self.ecx, place.local);
+            return;
+        };
 
         match self.ecx.machine.can_const_prop[place.local] {
             // Do nothing if the place is indirect.