]> git.lizzy.rs Git - rust.git/commitdiff
assert that nobody asks for mutable constants
authorRalf Jung <post@ralfj.de>
Wed, 28 Aug 2019 06:31:51 +0000 (08:31 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 15 Sep 2019 12:25:30 +0000 (14:25 +0200)
src/librustc_mir/interpret/intern.rs

index cf4f3fda090f3b2f90b8c217eac596db61dd02aa..606f506434579ff65b20389f1bef5af1eeb62d4c 100644 (file)
@@ -116,6 +116,10 @@ fn intern_shallow<'rt, 'mir, 'tcx>(
         // But we still intern that as immutable as the memory cannot be changed once the
         // initial value was computed.
         // Constants are never mutable.
+        assert_eq!(
+            mutability, Mutability::Immutable,
+            "Something went very wrong: mutability requested for a constant"
+        );
         alloc.mutability = Mutability::Immutable;
     };
     // link the alloc id to the actual allocation