diff options
| author | bors <bors@rust-lang.org> | 2023-12-01 04:08:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-01 04:08:22 +0000 |
| commit | a1c65db95cf79c23dceaf1b59038819f115bdf11 (patch) | |
| tree | a8a5aee613d7df12a5d0cd5f4827f53feb119321 /compiler/rustc_const_eval/src/interpret | |
| parent | c263ccf18571b4a3791e4c50dcae5473d6f9593a (diff) | |
| parent | a1b03e30675fcf1fadd9979f6c10a10182c7660e (diff) | |
| download | rust-a1c65db95cf79c23dceaf1b59038819f115bdf11.tar.gz rust-a1c65db95cf79c23dceaf1b59038819f115bdf11.zip | |
Auto merge of #118482 - RalfJung:interpret-local-type, r=WaffleLapkin
explain a good reason for why LocalValue does not store the type of the local As found out by `@lcnr` in https://github.com/rust-lang/rust/pull/112307, storing the type here can lead to subtle bugs when it gets out of sync with the MIR body. That's not the reason why the interpreter does it this way I think, but good thing we dodged that bullet. :)
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/eval_context.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 3bdfc1db913..32220b2aa76 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<Prov: Provenance> 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<Prov: Provenance = AllocId> { /// This local is not currently alive, and cannot be used at all. |
