Skip to content

Commit 22cc6c3

Browse files
committed
don't debug-print ConstValue in MIR pretty-printer
1 parent bd31ba0 commit 22cc6c3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

compiler/rustc_middle/src/mir/pretty.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,12 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
448448
self.push(&format!("+ user_ty: {:?}", user_ty));
449449
}
450450

451+
let fmt_val = |val: &ConstValue<'tcx>| match val {
452+
ConstValue::Scalar(s) => format!("Scalar({:?})", s),
453+
ConstValue::Slice { .. } => format!("Slice(..)"),
454+
ConstValue::ByRef { .. } => format!("ByRef(..)"),
455+
};
456+
451457
let val = match literal {
452458
ConstantKind::Ty(ct) => match ct.val() {
453459
ty::ConstKind::Param(p) => format!("Param({})", p),
@@ -457,7 +463,7 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
457463
uv.substs,
458464
uv.promoted,
459465
),
460-
ty::ConstKind::Value(val) => format!("Value({:?})", val),
466+
ty::ConstKind::Value(val) => format!("Value({})", fmt_val(&val)),
461467
ty::ConstKind::Error(_) => "Error".to_string(),
462468
// These variants shouldn't exist in the MIR.
463469
ty::ConstKind::Placeholder(_)
@@ -467,7 +473,7 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
467473
// To keep the diffs small, we render this like we render `ty::Const::Value`.
468474
//
469475
// This changes once `ty::Const::Value` is represented using valtrees.
470-
ConstantKind::Val(val, _) => format!("Value({:?})", val),
476+
ConstantKind::Val(val, _) => format!("Value({})", fmt_val(&val)),
471477
};
472478

473479
self.push(&format!("+ literal: Const {{ ty: {}, val: {} }}", literal.ty(), val));

0 commit comments

Comments
 (0)