Skip to content

Commit 26eeea6

Browse files
committed
Auto merge of #116069 - compiler-errors:debug-tuple, r=Nilstrieb
Fix debug printing of tuple Self-explanatory. Didn't create a UI test, but I guess I could -- not sure where debug output shows up in rustc_attrs to make a sufficient test, tho.
2 parents 70a7fe1 + 27fe1c3 commit 26eeea6

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
@@ -531,22 +531,18 @@ impl<I: Interner> DebugWithInfcx<I> for TyKind<I> {
531531
}
532532
Never => write!(f, "!"),
533533
Tuple(t) => {
534-
let mut iter = t.clone().into_iter();
535-
536534
write!(f, "(")?;
537-
538-
match iter.next() {
539-
None => return write!(f, ")"),
540-
Some(ty) => write!(f, "{:?}", &this.wrap(ty))?,
541-
};
542-
543-
match iter.next() {
544-
None => return write!(f, ",)"),
545-
Some(ty) => write!(f, "{:?})", &this.wrap(ty))?,
535+
let mut count = 0;
536+
for ty in t.clone() {
537+
if count > 0 {
538+
write!(f, ", ")?;
539+
}
540+
write!(f, "{:?}", &this.wrap(ty))?;
541+
count += 1;
546542
}
547-
548-
for ty in iter {
549-
write!(f, ", {:?}", &this.wrap(ty))?;
543+
// unary tuples need a trailing comma
544+
if count == 1 {
545+
write!(f, ",")?;
550546
}
551547
write!(f, ")")
552548
}

0 commit comments

Comments
 (0)