File tree 1 file changed +8
-2
lines changed
src/librustc_mir/interpret
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -230,8 +230,14 @@ pub(super) fn mir_assign_valid_types<'tcx>(
230
230
// late-bound lifetimes are still around and can lead to type
231
231
// differences. So we compare ignoring lifetimes.
232
232
if equal_up_to_regions ( tcx, param_env, src. ty , dest. ty ) {
233
- // Make sure the layout is equal, too -- just to be safe. Miri really needs layout equality.
234
- assert_eq ! ( src. layout, dest. layout) ;
233
+ // Make sure the layout is equal, too -- just to be safe. Miri really
234
+ // needs layout equality. For performance reason we skip this check when
235
+ // the types are equal. Equal types *can* have different layouts when
236
+ // enum downcast is involved (as enum variants carry the type of the
237
+ // enum), but those should never occur in assignments.
238
+ if cfg ! ( debug_assertions) || src. ty != dest. ty {
239
+ assert_eq ! ( src. layout, dest. layout) ;
240
+ }
235
241
true
236
242
} else {
237
243
false
You can’t perform that action at this time.
0 commit comments