about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-04-29 14:56:40 +0200
committerRalf Jung <post@ralfj.de>2020-04-29 14:56:40 +0200
commit07772fcf6fca44217439154aa37e4854dd5aef34 (patch)
treef5c7022bcca71d9614d3aba332b05ebe12fbce46 /src
parenta03355dea0b7d042b8b4e01d75bba6c7489e3a14 (diff)
downloadrust-07772fcf6fca44217439154aa37e4854dd5aef34.tar.gz
rust-07772fcf6fca44217439154aa37e4854dd5aef34.zip
expand comment in memory.rs with extra soundness concerns
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/interpret/memory.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs
index 0d0ed465c1c..8560594b583 100644
--- a/src/librustc_mir/interpret/memory.rs
+++ b/src/librustc_mir/interpret/memory.rs
@@ -453,7 +453,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
                 // thing here: one maps to `GlobalAlloc::Static`, this is the "lazy" ID,
                 // and the other one is maps to `GlobalAlloc::Memory`, this is returned by
                 // `const_eval_raw` and it is the "resolved" ID.
-                // The resolved ID is never used by the interpreted progrma, it is hidden.
+                // The resolved ID is never used by the interpreted program, it is hidden.
+                // This is relied upon for soundness of const-patterns; a pointer to the resolved
+                // ID would "sidestep" the checks that make sure consts do not point to statics!
                 // The `GlobalAlloc::Memory` branch here is still reachable though; when a static
                 // contains a reference to memory that was created during its evaluation (i.e., not
                 // to another static), those inner references only exist in "resolved" form.