Skip to content

Commit a1c65db

Browse files
committed
Auto merge of rust-lang#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 rust-lang#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. :)
2 parents c263ccf + a1b03e3 commit a1c65db

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

compiler/rustc_const_eval/src/interpret/eval_context.rs

+3
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ impl<Prov: Provenance> std::fmt::Debug for LocalState<'_, Prov> {
173173
}
174174

175175
/// Current value of a local variable
176+
///
177+
/// This does not store the type of the local; the type is given by `body.local_decls` and can never
178+
/// change, so by not storing here we avoid having to maintain that as an invariant.
176179
#[derive(Copy, Clone, Debug)] // Miri debug-prints these
177180
pub(super) enum LocalValue<Prov: Provenance = AllocId> {
178181
/// This local is not currently alive, and cannot be used at all.

0 commit comments

Comments
 (0)