1
Fork 0

Rollup merge of #139833 - nnethercote:fix-139633, r=oli-obk

Fix some HIR pretty-printing problems

r? `@oli-obk`
This commit is contained in:
Stuart Cook 2025-04-15 15:47:32 +10:00 committed by GitHub
commit 4d5284a866
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 59 additions and 4 deletions

View file

@ -1871,10 +1871,11 @@ impl<'a> State<'a> {
fn print_pat(&mut self, pat: &hir::Pat<'_>) {
self.maybe_print_comment(pat.span.lo());
self.ann.pre(self, AnnNode::Pat(pat));
// Pat isn't normalized, but the beauty of it
// is that it doesn't matter
// Pat isn't normalized, but the beauty of it is that it doesn't matter.
match pat.kind {
PatKind::Missing => unreachable!(),
// Printing `_` isn't ideal for a missing pattern, but it's easy and good enough.
// E.g. `fn(u32)` gets printed as `fn(_: u32)`.
PatKind::Missing => self.word("_"),
PatKind::Wild => self.word("_"),
PatKind::Never => self.word("!"),
PatKind::Binding(BindingMode(by_ref, mutbl), _, ident, sub) => {
@ -2164,7 +2165,9 @@ impl<'a> State<'a> {
s.end();
});
if decl.c_variadic {
self.word(", ");
if !decl.inputs.is_empty() {
self.word(", ");
}
print_arg(self, None);
self.word("...");
}