Skip to content

Commit 07772fc

Browse files
committed
expand comment in memory.rs with extra soundness concerns
1 parent a03355d commit 07772fc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/librustc_mir/interpret/memory.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
453453
// thing here: one maps to `GlobalAlloc::Static`, this is the "lazy" ID,
454454
// and the other one is maps to `GlobalAlloc::Memory`, this is returned by
455455
// `const_eval_raw` and it is the "resolved" ID.
456-
// The resolved ID is never used by the interpreted progrma, it is hidden.
456+
// The resolved ID is never used by the interpreted program, it is hidden.
457+
// This is relied upon for soundness of const-patterns; a pointer to the resolved
458+
// ID would "sidestep" the checks that make sure consts do not point to statics!
457459
// The `GlobalAlloc::Memory` branch here is still reachable though; when a static
458460
// contains a reference to memory that was created during its evaluation (i.e., not
459461
// to another static), those inner references only exist in "resolved" form.

0 commit comments

Comments
 (0)