Skip to content

Commit

Permalink
Fix debug printing of tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Sep 22, 2023
1 parent 0fd7ce9 commit 27fe1c3
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions compiler/rustc_type_ir/src/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,22 +564,18 @@ impl<I: Interner> DebugWithInfcx<I> for TyKind<I> {
}
Never => write!(f, "!"),
Tuple(t) => {
let mut iter = t.clone().into_iter();

write!(f, "(")?;

match iter.next() {
None => return write!(f, ")"),
Some(ty) => write!(f, "{:?}", &this.wrap(ty))?,
};

match iter.next() {
None => return write!(f, ",)"),
Some(ty) => write!(f, "{:?})", &this.wrap(ty))?,
let mut count = 0;
for ty in t.clone() {
if count > 0 {
write!(f, ", ")?;
}
write!(f, "{:?}", &this.wrap(ty))?;
count += 1;
}

for ty in iter {
write!(f, ", {:?}", &this.wrap(ty))?;
// unary tuples need a trailing comma
if count == 1 {
write!(f, ",")?;
}
write!(f, ")")
}
Expand Down

0 comments on commit 27fe1c3

Please sign in to comment.