Fix HIR param pretty printing some more.

Anonymous params are currently represented with `kw::Empty`, so handle
that properly. (Subsequent commits will get rid of the `kw::Empty`.)
This commit is contained in:
Nicholas Nethercote 2025-03-14 07:29:19 +11:00
parent 958bc7b365
commit bebd91feb3
2 changed files with 7 additions and 5 deletions

View file

@ -2148,9 +2148,11 @@ impl<'a> State<'a> {
s.print_implicit_self(&decl.implicit_self);
} else {
if let Some(arg_name) = arg_names.get(i) {
if arg_name.name != kw::Empty {
s.word(arg_name.to_string());
s.word(":");
s.space();
}
} else if let Some(body_id) = body_id {
s.ann.nested(s, Nested::BodyParamPat(body_id, i));
s.word(":");

View file

@ -27,12 +27,12 @@ impl S {
// because they had similar problems. But the pretty-printing tests currently
// can't contain compile errors.
fn bare_fn(x: fn(: u32, _: u32, a: u32)) { }
fn bare_fn(x: fn(u32, _: u32, a: u32)) { }
extern "C" {
unsafe fn foreign_fn(_: u32, a: u32);
}
trait T {
fn trait_fn(: u32, _: u32, a: u32);
fn trait_fn(u32, _: u32, a: u32);
}