};
p!(print_value_path(instance.def_id(), instance.substs));
}
- // For zsts just print their type as their value gives no extra information
- (Scalar::Raw { size: 0, .. }, _) => p!(print(ty)),
+ // For function type zsts just printing the type is enough
+ (Scalar::Raw { size: 0, .. }, ty::FnDef(..)) => p!(print(ty)),
+ // Empty tuples are frequently occurring, so don't print the fallback.
+ (Scalar::Raw { size: 0, .. }, ty::Tuple(ts)) if ts.is_empty() => p!(write("()")),
+ // Zero element arrays have a trivial representation.
+ (
+ Scalar::Raw { size: 0, .. },
+ ty::Array(
+ _,
+ ty::Const {
+ val: ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { data: 0, .. })),
+ ..
+ },
+ ),
+ ) => p!(write("[]")),
// Nontrivial types with scalar bit representation
(Scalar::Raw { data, size }, _) => {
let print = |mut this: Self| {
- write!(this, "transmute(0x{:01$x})", data, size as usize * 2)?;
+ if size == 0 {
+ write!(this, "transmute(())")?;
+ } else {
+ write!(this, "transmute(0x{:01$x})", data, size as usize * 2)?;
+ }
Ok(this)
};
self = if print_ty {
// _2 = const ();
// StorageLive(_3);
// _3 = const ();
-// _1 = const ((), ());
+// _1 = const {transmute(()): ((), ())};
// StorageDead(_3);
// StorageDead(_2);
// StorageDead(_1);
// _7 = const ();
// StorageDead(_7);
// StorageDead(_6);
-// _4 = const use_zst(const ((), ())) -> bb1;
+// _4 = const use_zst(const {transmute(()): ((), ())}) -> bb1;
// }
// bb1: {
// StorageDead(_4);
// }
// bb0: {
// StorageLive(_1);
-// _1 = const use_zst(const ((), ())) -> bb1;
+// _1 = const use_zst(const {transmute(()): ((), ())}) -> bb1;
// }
// bb1: {
// StorageDead(_1);