about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2020-06-03 13:45:56 +0200
committerWesley Wiser <wwiser@gmail.com>2020-06-07 10:22:20 -0400
commit20abc70e04eefa252e5a8bfe934cb54c51c1da37 (patch)
tree72e12ad7e8b1d24780e2ec4866dd5730b7d932ad
parenta2fc33e0c87a258542cd12d6ffae52c43aa3785a (diff)
downloadrust-20abc70e04eefa252e5a8bfe934cb54c51c1da37.tar.gz
rust-20abc70e04eefa252e5a8bfe934cb54c51c1da37.zip
Don't intern memory in const prop.
This isn't sound without validation. We don't want to report errors in case of failure to intern and validate, we just don't want to const prop. Interning and const prop is not built for this, let's not do it until we have a clearer picture on aggregate propagation.
-rw-r--r--src/librustc_mir/interpret/intern.rs12
-rw-r--r--src/librustc_mir/transform/const_prop.rs12
2 files changed, 10 insertions, 14 deletions
diff --git a/src/librustc_mir/interpret/intern.rs b/src/librustc_mir/interpret/intern.rs
index 02a7f24a1e3..4c1cf1b56ae 100644
--- a/src/librustc_mir/interpret/intern.rs
+++ b/src/librustc_mir/interpret/intern.rs
@@ -294,7 +294,6 @@ pub enum InternKind {
     Static(hir::Mutability),
     Constant,
     Promoted,
-    ConstProp,
 }
 
 /// Intern `ret` and everything it references.
@@ -315,9 +314,7 @@ pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx>>(
     let base_intern_mode = match intern_kind {
         InternKind::Static(mutbl) => InternMode::Static(mutbl),
         // FIXME: what about array lengths, array initializers?
-        InternKind::Constant | InternKind::ConstProp | InternKind::Promoted => {
-            InternMode::ConstBase
-        }
+        InternKind::Constant | InternKind::Promoted => InternMode::ConstBase,
     };
 
     // Type based interning.
@@ -359,7 +356,10 @@ pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx>>(
             Err(error) => {
                 ecx.tcx.sess.delay_span_bug(
                     ecx.tcx.span,
-                    "error during interning should later cause validation failure",
+                    &format!(
+                        "error during interning should later cause validation failure: {}",
+                        error
+                    ),
                 );
                 // Some errors shouldn't come up because creating them causes
                 // an allocation, which we should avoid. When that happens,
@@ -400,7 +400,7 @@ pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx>>(
                     // immutability is so important.
                     alloc.mutability = Mutability::Not;
                 }
-                InternKind::Constant | InternKind::ConstProp => {
+                InternKind::Constant => {
                     // If it's a constant, we should not have any "leftovers" as everything
                     // is tracked by const-checking.
                     // FIXME: downgrade this to a warning? It rejects some legitimate consts,
diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs
index 92000e64113..97e5b8bc047 100644
--- a/src/librustc_mir/transform/const_prop.rs
+++ b/src/librustc_mir/transform/const_prop.rs
@@ -27,9 +27,9 @@ use rustc_trait_selection::traits;
 
 use crate::const_eval::error_to_const_error;
 use crate::interpret::{
-    self, compile_time_machine, intern_const_alloc_recursive, AllocId, Allocation, Frame, ImmTy,
-    Immediate, InternKind, InterpCx, LocalState, LocalValue, Memory, MemoryKind, OpTy,
-    Operand as InterpOperand, PlaceTy, Pointer, ScalarMaybeUninit, StackPopCleanup,
+    self, compile_time_machine, AllocId, Allocation, Frame, ImmTy, Immediate, InterpCx, LocalState,
+    LocalValue, Memory, MemoryKind, OpTy, Operand as InterpOperand, PlaceTy, Pointer,
+    ScalarMaybeUninit, StackPopCleanup,
 };
 use crate::transform::{MirPass, MirSource};
 
@@ -707,11 +707,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
                 ScalarMaybeUninit::Scalar(l),
                 ScalarMaybeUninit::Scalar(r),
             )) => l.is_bits() && r.is_bits(),
-            interpret::Operand::Indirect(_) if mir_opt_level >= 2 => {
-                let mplace = op.assert_mem_place(&self.ecx);
-                intern_const_alloc_recursive(&mut self.ecx, InternKind::ConstProp, mplace, false);
-                true
-            }
+            interpret::Operand::Indirect(_) if mir_opt_level >= 2 => true,
             _ => false,
         }
     }