Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix debug printing of tuple #116069

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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