Skip to content

Commit 27fe1c3

Browse files
Fix debug printing of tuple
1 parent 0fd7ce9 commit 27fe1c3

File tree

1 file changed

+10
-14
lines changed
  • compiler/rustc_type_ir/src

1 file changed

+10
-14
lines changed

compiler/rustc_type_ir/src/sty.rs

+10-14
Original file line numberDiff line numberDiff line change
@@ -564,22 +564,18 @@ impl<I: Interner> DebugWithInfcx<I> for TyKind<I> {
564564
}
565565
Never => write!(f, "!"),
566566
Tuple(t) => {
567-
let mut iter = t.clone().into_iter();
568-
569567
write!(f, "(")?;
570-
571-
match iter.next() {
572-
None => return write!(f, ")"),
573-
Some(ty) => write!(f, "{:?}", &this.wrap(ty))?,
574-
};
575-
576-
match iter.next() {
577-
None => return write!(f, ",)"),
578-
Some(ty) => write!(f, "{:?})", &this.wrap(ty))?,
568+
let mut count = 0;
569+
for ty in t.clone() {
570+
if count > 0 {
571+
write!(f, ", ")?;
572+
}
573+
write!(f, "{:?}", &this.wrap(ty))?;
574+
count += 1;
579575
}
580-
581-
for ty in iter {
582-
write!(f, ", {:?}", &this.wrap(ty))?;
576+
// unary tuples need a trailing comma
577+
if count == 1 {
578+
write!(f, ",")?;
583579
}
584580
write!(f, ")")
585581
}

0 commit comments

Comments
 (0)