Fix type formatting

This commit is contained in:
Shunsuke Shibayama 2022-12-14 08:04:48 +09:00
parent 393ce2d94a
commit 8528096a31
2 changed files with 23 additions and 15 deletions

View file

@ -255,14 +255,18 @@ impl<T: LimitedDisplay> LimitedDisplay for FreeKind<T> {
constraint,
} => {
if *lev == GENERIC_LEVEL {
write!(f, "{name}(")?;
constraint.limited_fmt(f, limit - 1)?;
write!(f, ")")?;
} else {
write!(f, "?{name}(")?;
constraint.limited_fmt(f, limit - 1)?;
write!(f, ")")?;
write!(f, "{name}")?;
if cfg!(feature = "debug") {
write!(f, "(")?;
constraint.limited_fmt(f, limit - 1)?;
write!(f, ")")?;
}
} else {
write!(f, "?{name}")?;
if cfg!(feature = "debug") {
write!(f, "(")?;
constraint.limited_fmt(f, limit - 1)?;
write!(f, ")")?;
write!(f, "[{lev}]")?;
}
}
@ -274,14 +278,18 @@ impl<T: LimitedDisplay> LimitedDisplay for FreeKind<T> {
constraint,
} => {
if *lev == GENERIC_LEVEL {
write!(f, "%{id}(")?;
constraint.limited_fmt(f, limit - 1)?;
write!(f, ")")?;
} else {
write!(f, "?{id}(")?;
constraint.limited_fmt(f, limit - 1)?;
write!(f, ")")?;
write!(f, "%{id}")?;
if cfg!(feature = "debug") {
write!(f, "(")?;
constraint.limited_fmt(f, limit - 1)?;
write!(f, ")")?;
}
} else {
write!(f, "?{id}")?;
if cfg!(feature = "debug") {
write!(f, "(")?;
constraint.limited_fmt(f, limit - 1)?;
write!(f, ")")?;
write!(f, "[{lev}]")?;
}
}

View file

@ -1192,7 +1192,7 @@ impl LimitedDisplay for Type {
write!(f, "|")?;
for (i, (name, constr)) in qvars.iter().enumerate() {
if i != 0 {
write!(f, "; ")?;
write!(f, ", ")?;
}
write!(f, "{name}")?;
constr.limited_fmt(f, limit - 1)?;