Skip to content

Commit a089801

Browse files
committed
clarify comment
1 parent a84e2a0 commit a089801

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/librustc_mir/const_eval/machine.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,9 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
343343
// Machine configuration does not allow us to read statics
344344
// (e.g., `const` initializer).
345345
// See const_eval::machine::MemoryExtra::can_access_statics for why
346-
// this check is so important.
346+
// this check is so important: if we could read statics, we could read pointers
347+
// to mutable allocations *inside* statics. These allocations are not themselves
348+
// statics, so pointers to them can get around the check in `validity.rs`.
347349
Err(ConstEvalErrKind::ConstAccessesStatic.into())
348350
} else {
349351
// Immutable global, this read is fine.

0 commit comments

Comments
 (0)