about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2019-06-11 16:17:08 +0200
committerOliver Scherer <github35764891676564198441@oli-obk.de>2019-06-19 09:52:35 +0200
commit9e3fbcfd571d3ed4c0729a1ae822377bc075fcd6 (patch)
tree8668da7fd272dbfa789d4ed0369ba7f4722b9151
parentd6fa4070bea1cf94b6fbab5028057d5604c600ee (diff)
downloadrust-9e3fbcfd571d3ed4c0729a1ae822377bc075fcd6.tar.gz
rust-9e3fbcfd571d3ed4c0729a1ae822377bc075fcd6.zip
Merge `StaticMut` and `Static` logic
-rw-r--r--src/librustc_mir/interpret/intern.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/librustc_mir/interpret/intern.rs b/src/librustc_mir/interpret/intern.rs
index a7aee9407a4..c450e3be1dd 100644
--- a/src/librustc_mir/interpret/intern.rs
+++ b/src/librustc_mir/interpret/intern.rs
@@ -44,9 +44,9 @@ struct InternVisitor<'rt, 'a: 'rt, 'mir: 'rt, 'tcx: 'a+'rt+'mir> {
 
 #[derive(Copy, Clone, Debug, PartialEq, Hash, Eq)]
 enum InternMode {
-    /// Mutable references don't change the `mutability` field to `Immutable`
-    StaticMut,
-    /// Mutable references must in fact be immutable due to their surrounding immutability
+    /// Mutable references must in fact be immutable due to their surrounding immutability in a
+    /// `static`. In a `static mut` we start out as mutable and thus can also contain further `&mtu`
+    /// that will actually be treated as mutable.
     Static,
     /// UnsafeCell is OK in the value of a constant, but not behind references in a constant
     ConstBase,
@@ -171,10 +171,10 @@ for
                 // This is not an inherent limitation, but one that we know to be true, because
                 // const qualification enforces it. We can lift it in the future.
                 match (self.mode, mutability) {
-                    // all is "good and well" in the unsoundness of `static mut`
-                    (InternMode::StaticMut, _) => {},
                     // immutable references are fine everywhere
                     (_, hir::Mutability::MutImmutable) => {},
+                    // all is "good and well" in the unsoundness of `static mut`
+
                     // mutable references are ok in `static`. Either they are treated as immutable
                     // because they are behind an immutable one, or they are behind an `UnsafeCell`
                     // and thus ok.
@@ -251,7 +251,7 @@ pub fn intern_const_alloc_recursive(
         Some(hir::Mutability::MutImmutable) => (Mutability::Immutable, InternMode::Static),
         None => (Mutability::Immutable, InternMode::ConstBase),
         // `static mut` doesn't care about interior mutability, it's mutable anyway
-        Some(hir::Mutability::MutMutable) => (Mutability::Mutable, InternMode::StaticMut),
+        Some(hir::Mutability::MutMutable) => (Mutability::Mutable, InternMode::Static),
     };
 
     // type based interning