1
Fork 0

make more pretty

This commit is contained in:
Boxy 2023-09-15 16:32:27 +01:00
parent cbcf9a5368
commit b2bf4b66f8
8 changed files with 51 additions and 107 deletions

View file

@ -82,6 +82,7 @@ use std::ops::{Bound, Deref};
impl<'tcx> Interner for TyCtxt<'tcx> {
type AdtDef = ty::AdtDef<'tcx>;
type GenericArgsRef = ty::GenericArgsRef<'tcx>;
type GenericArg = ty::GenericArg<'tcx>;
type DefId = DefId;
type Binder<T> = Binder<'tcx, T>;
type Ty = Ty<'tcx>;

View file

@ -41,7 +41,12 @@ pub trait HashStableContext {}
pub trait Interner: Sized {
type AdtDef: Clone + Debug + Hash + Ord;
type GenericArgsRef: Clone + DebugWithInfcx<Self> + Hash + Ord;
type GenericArgsRef: Clone
+ DebugWithInfcx<Self>
+ Hash
+ Ord
+ IntoIterator<Item = Self::GenericArg>;
type GenericArg: Clone + DebugWithInfcx<Self> + Hash + Ord;
type DefId: Clone + Debug + Hash + Ord;
type Binder<T>;
type Ty: Clone + DebugWithInfcx<Self> + Hash + Ord;

View file

@ -517,7 +517,21 @@ impl<I: Interner> DebugWithInfcx<I> for TyKind<I> {
Int(i) => write!(f, "{i:?}"),
Uint(u) => write!(f, "{u:?}"),
Float(float) => write!(f, "{float:?}"),
Adt(d, s) => f.debug_tuple_field2_finish("Adt", d, &this.wrap(s)),
Adt(d, s) => {
write!(f, "{d:?}")?;
let mut s = s.clone().into_iter();
let first = s.next();
match first {
Some(first) => write!(f, "<{:?}", first)?,
None => return Ok(()),
};
for arg in s {
write!(f, ", {:?}", arg)?;
}
write!(f, ">")
}
Foreign(d) => f.debug_tuple_field1_finish("Foreign", d),
Str => write!(f, "str"),
Array(t, c) => write!(f, "[{:?}; {:?}]", &this.wrap(t), &this.wrap(c)),