about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-09-22 17:59:52 +0000
committerMichael Goulet <michael@errs.io>2023-09-22 17:59:52 +0000
commit27fe1c380b481304a75411ac96cac52d5a8f6c2c (patch)
tree300bcda34db214200d79275064779e80883d4ace
parent0fd7ce99b0508aff7f7a2c639871de4e8080e3f8 (diff)
downloadrust-27fe1c380b481304a75411ac96cac52d5a8f6c2c.tar.gz
rust-27fe1c380b481304a75411ac96cac52d5a8f6c2c.zip
Fix debug printing of tuple
-rw-r--r--compiler/rustc_type_ir/src/sty.rs24
1 files changed, 10 insertions, 14 deletions
diff --git a/compiler/rustc_type_ir/src/sty.rs b/compiler/rustc_type_ir/src/sty.rs
index b574cdcc879..380d70589bc 100644
--- a/compiler/rustc_type_ir/src/sty.rs
+++ b/compiler/rustc_type_ir/src/sty.rs
@@ -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, ")")
             }