Don't print all zsts as their type as it makes no sense for more complex examples (e.g. structs)
This commit is contained in:
parent
1191eb4585
commit
154f3f19ab
@ -999,12 +999,29 @@ pub trait PrettyPrinter<'tcx>:
|
||||
};
|
||||
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 {
|
||||
|
@ -38,7 +38,7 @@ fn main() {
|
||||
// _2 = const ();
|
||||
// StorageLive(_3);
|
||||
// _3 = const ();
|
||||
// _1 = const ((), ());
|
||||
// _1 = const {transmute(()): ((), ())};
|
||||
// StorageDead(_3);
|
||||
// StorageDead(_2);
|
||||
// StorageDead(_1);
|
||||
@ -49,7 +49,7 @@ fn main() {
|
||||
// _7 = const ();
|
||||
// StorageDead(_7);
|
||||
// StorageDead(_6);
|
||||
// _4 = const use_zst(const ((), ())) -> bb1;
|
||||
// _4 = const use_zst(const {transmute(()): ((), ())}) -> bb1;
|
||||
// }
|
||||
// bb1: {
|
||||
// StorageDead(_4);
|
||||
@ -75,7 +75,7 @@ fn main() {
|
||||
// }
|
||||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = const use_zst(const ((), ())) -> bb1;
|
||||
// _1 = const use_zst(const {transmute(()): ((), ())}) -> bb1;
|
||||
// }
|
||||
// bb1: {
|
||||
// StorageDead(_1);
|
||||
|
Loading…
Reference in New Issue
Block a user