From a1b03e30675fcf1fadd9979f6c10a10182c7660e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 30 Nov 2023 17:01:28 +0100 Subject: [PATCH] explain a good reason for why LocalValue does not store the type of the local --- compiler/rustc_const_eval/src/interpret/eval_context.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 3bdfc1db913a4..32220b2aa7635 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -173,6 +173,9 @@ impl std::fmt::Debug for LocalState<'_, Prov> { } /// Current value of a local variable +/// +/// This does not store the type of the local; the type is given by `body.local_decls` and can never +/// change, so by not storing here we avoid having to maintain that as an invariant. #[derive(Copy, Clone, Debug)] // Miri debug-prints these pub(super) enum LocalValue { /// This local is not currently alive, and cannot be used at all.