about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2021-12-22 14:35:17 -0500
committerAaron Hill <aa1ronham@gmail.com>2021-12-22 14:36:34 -0500
commitcac431ba750c4f079690731b976bc67d979cb8e3 (patch)
tree3f58e4c7c63c2d0c55ed31e7736927005aece152 /compiler/rustc_const_eval/src/interpret
parente100ec5bc7cd768ec17d75448b29c9ab4a39272b (diff)
downloadrust-cac431ba750c4f079690731b976bc67d979cb8e3.tar.gz
rust-cac431ba750c4f079690731b976bc67d979cb8e3.zip
Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt`
The `AggregateKind` enum ends up in the final mir `Body`. Currently,
any changes to `AdtDef` (regardless of how significant they are)
will legitimately cause the overall result of `optimized_mir` to change,
invalidating any codegen re-use involving that mir.

This will get worse once we start hashing the `Span` inside `FieldDef`
(which is itself contained in `AdtDef`).

To try to reduce these kinds of invalidations, this commit changes
`AggregateKind::Adt` to store just the `DefId`, instead of the full
`AdtDef`. This allows the result of `optimized_mir` to be unchanged
if the `AdtDef` changes in a way that doesn't actually affect any
of the MIR we build.
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
-rw-r--r--compiler/rustc_const_eval/src/interpret/step.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs
index 992cef1cb6a..6e37aae0f5e 100644
--- a/compiler/rustc_const_eval/src/interpret/step.rs
+++ b/compiler/rustc_const_eval/src/interpret/step.rs
@@ -199,9 +199,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
             Aggregate(ref kind, ref operands) => {
                 // active_field_index is for union initialization.
                 let (dest, active_field_index) = match **kind {
-                    mir::AggregateKind::Adt(adt_def, variant_index, _, _, active_field_index) => {
+                    mir::AggregateKind::Adt(adt_did, variant_index, _, _, active_field_index) => {
                         self.write_discriminant(variant_index, &dest)?;
-                        if adt_def.is_enum() {
+                        if self.tcx.adt_def(adt_did).is_enum() {
                             assert!(active_field_index.is_none());
                             (self.place_downcast(&dest, variant_index)?, None)
                         } else {