about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-03-31 15:25:12 +0200
committerRalf Jung <post@ralfj.de>2020-03-31 15:27:45 +0200
commitafe1ffb19004fc472294b8cacc34c64d28dd9abc (patch)
tree6f72da2e21ca8f8f663df2bcbb8798c78ad827ac
parent2113659479a82ea69633b23ef710b58ab127755e (diff)
downloadrust-afe1ffb19004fc472294b8cacc34c64d28dd9abc.tar.gz
rust-afe1ffb19004fc472294b8cacc34c64d28dd9abc.zip
remove unnecessary relocation check in const_prop
-rw-r--r--src/librustc_mir/transform/const_prop.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs
index 8e004e45b7a..f1ddf3c635f 100644
--- a/src/librustc_mir/transform/const_prop.rs
+++ b/src/librustc_mir/transform/const_prop.rs
@@ -274,19 +274,16 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine {
         _memory_extra: &(),
         _alloc_id: AllocId,
         allocation: &Allocation<Self::PointerTag, Self::AllocExtra>,
-        static_def_id: Option<DefId>,
+        _static_def_id: Option<DefId>,
         is_write: bool,
     ) -> InterpResult<'tcx> {
         if is_write {
             throw_machine_stop_str!("can't write to global");
         }
-        // If the static allocation is mutable or if it has relocations (it may be legal to mutate
-        // the memory behind that in the future), then we can't const prop it.
+        // If the static allocation is mutable, then we can't const prop it as its content
+        // might be different at runtime.
         if allocation.mutability == Mutability::Mut {
-            throw_machine_stop_str!("can't eval mutable globals in ConstProp");
-        }
-        if static_def_id.is_some() && allocation.relocations().len() > 0 {
-            throw_machine_stop_str!("can't eval statics with pointers in ConstProp");
+            throw_machine_stop_str!("can't access mutable globals in ConstProp");
         }
 
         Ok(())