From a0898019485fd0920957444b7b387eec5f2b112d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 28 Apr 2020 23:54:47 +0200 Subject: [PATCH] clarify comment --- src/librustc_mir/const_eval/machine.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/const_eval/machine.rs b/src/librustc_mir/const_eval/machine.rs index ce9d25599ff..7c1ab261eb9 100644 --- a/src/librustc_mir/const_eval/machine.rs +++ b/src/librustc_mir/const_eval/machine.rs @@ -343,7 +343,9 @@ fn before_access_global( // Machine configuration does not allow us to read statics // (e.g., `const` initializer). // See const_eval::machine::MemoryExtra::can_access_statics for why - // this check is so important. + // this check is so important: if we could read statics, we could read pointers + // to mutable allocations *inside* statics. These allocations are not themselves + // statics, so pointers to them can get around the check in `validity.rs`. Err(ConstEvalErrKind::ConstAccessesStatic.into()) } else { // Immutable global, this read is fine.