Rollup merge of #116374 - ouz-a:correct_message, r=RalfJung

Print normalized ty

Inside `mir_assign_valid_types` we are comparing normalized type of `mir_place` but in debug message we are not printing the normalized value, this changes that.
This commit is contained in:
Matthias Krüger 2023-10-03 12:24:13 +02:00 committed by GitHub
commit 7ba649806f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 20 deletions

View file

@ -670,19 +670,24 @@ pub fn eval_place_to_op(
trace!("eval_place_to_op: got {:?}", op);
// Sanity-check the type we ended up with.
debug_assert!(
mir_assign_valid_types(
if cfg!(debug_assertions) {
let normalized_place_ty = self.subst_from_current_frame_and_normalize_erasing_regions(
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty,
)?;
if !mir_assign_valid_types(
*self.tcx,
self.param_env,
self.layout_of(self.subst_from_current_frame_and_normalize_erasing_regions(
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty
)?)?,
self.layout_of(normalized_place_ty)?,
op.layout,
),
"eval_place of a MIR place with type {:?} produced an interpreter operand with type {}",
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty,
op.layout.ty,
);
) {
span_bug!(
self.cur_span(),
"eval_place of a MIR place with type {} produced an interpreter operand with type {}",
normalized_place_ty,
op.layout.ty,
)
}
}
Ok(op)
}

View file

@ -573,19 +573,24 @@ pub fn eval_place(
trace!("{:?}", self.dump_place(&place));
// Sanity-check the type we ended up with.
debug_assert!(
mir_assign_valid_types(
if cfg!(debug_assertions) {
let normalized_place_ty = self.subst_from_current_frame_and_normalize_erasing_regions(
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty,
)?;
if !mir_assign_valid_types(
*self.tcx,
self.param_env,
self.layout_of(self.subst_from_current_frame_and_normalize_erasing_regions(
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty
)?)?,
self.layout_of(normalized_place_ty)?,
place.layout,
),
"eval_place of a MIR place with type {:?} produced an interpreter place with type {}",
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty,
place.layout.ty,
);
) {
span_bug!(
self.cur_span(),
"eval_place of a MIR place with type {} produced an interpreter place with type {}",
normalized_place_ty,
place.layout.ty,
)
}
}
Ok(place)
}