Skip to content

Commit

Permalink
reduce sanity check in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jun 24, 2020
1 parent a593728 commit 35911ee
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/librustc_mir/interpret/eval_context.rs
Expand Up @@ -230,8 +230,14 @@ pub(super) fn mir_assign_valid_types<'tcx>(
// late-bound lifetimes are still around and can lead to type
// differences. So we compare ignoring lifetimes.
if equal_up_to_regions(tcx, param_env, src.ty, dest.ty) {
// Make sure the layout is equal, too -- just to be safe. Miri really needs layout equality.
assert_eq!(src.layout, dest.layout);
// Make sure the layout is equal, too -- just to be safe. Miri really
// needs layout equality. For performance reason we skip this check when
// the types are equal. Equal types *can* have different layouts when
// enum downcast is involved (as enum variants carry the type of the
// enum), but those should never occur in assignments.
if cfg!(debug_assertions) || src.ty != dest.ty {
assert_eq!(src.layout, dest.layout);
}
true
} else {
false
Expand Down

0 comments on commit 35911ee

Please sign in to comment.