Skip to content

Commit 42c39b3

Browse files
committed
print normalized ty
1 parent 4f75af9 commit 42c39b3

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

compiler/rustc_const_eval/src/interpret/operand.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -670,19 +670,24 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
670670

671671
trace!("eval_place_to_op: got {:?}", op);
672672
// Sanity-check the type we ended up with.
673-
debug_assert!(
674-
mir_assign_valid_types(
673+
if cfg!(debug_assertions) {
674+
let normalized_place_ty = self.subst_from_current_frame_and_normalize_erasing_regions(
675+
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty,
676+
)?;
677+
if !mir_assign_valid_types(
675678
*self.tcx,
676679
self.param_env,
677-
self.layout_of(self.subst_from_current_frame_and_normalize_erasing_regions(
678-
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty
679-
)?)?,
680+
self.layout_of(normalized_place_ty)?,
680681
op.layout,
681-
),
682-
"eval_place of a MIR place with type {:?} produced an interpreter operand with type {}",
683-
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty,
684-
op.layout.ty,
685-
);
682+
) {
683+
span_bug!(
684+
self.cur_span(),
685+
"eval_place of a MIR place with type {} produced an interpreter operand with type {}",
686+
normalized_place_ty,
687+
op.layout.ty,
688+
)
689+
}
690+
}
686691
Ok(op)
687692
}
688693

compiler/rustc_const_eval/src/interpret/place.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -573,19 +573,24 @@ where
573573

574574
trace!("{:?}", self.dump_place(&place));
575575
// Sanity-check the type we ended up with.
576-
debug_assert!(
577-
mir_assign_valid_types(
576+
if cfg!(debug_assertions) {
577+
let normalized_place_ty = self.subst_from_current_frame_and_normalize_erasing_regions(
578+
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty,
579+
)?;
580+
if !mir_assign_valid_types(
578581
*self.tcx,
579582
self.param_env,
580-
self.layout_of(self.subst_from_current_frame_and_normalize_erasing_regions(
581-
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty
582-
)?)?,
583+
self.layout_of(normalized_place_ty)?,
583584
place.layout,
584-
),
585-
"eval_place of a MIR place with type {:?} produced an interpreter place with type {}",
586-
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty,
587-
place.layout.ty,
588-
);
585+
) {
586+
span_bug!(
587+
self.cur_span(),
588+
"eval_place of a MIR place with type {} produced an interpreter place with type {}",
589+
normalized_place_ty,
590+
place.layout.ty,
591+
)
592+
}
593+
}
589594
Ok(place)
590595
}
591596

0 commit comments

Comments
 (0)