Skip to content

Commit bebd91f

Browse files
committed
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`.)
1 parent 958bc7b commit bebd91f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

compiler/rustc_hir_pretty/src/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -2148,9 +2148,11 @@ impl<'a> State<'a> {
21482148
s.print_implicit_self(&decl.implicit_self);
21492149
} else {
21502150
if let Some(arg_name) = arg_names.get(i) {
2151-
s.word(arg_name.to_string());
2152-
s.word(":");
2153-
s.space();
2151+
if arg_name.name != kw::Empty {
2152+
s.word(arg_name.to_string());
2153+
s.word(":");
2154+
s.space();
2155+
}
21542156
} else if let Some(body_id) = body_id {
21552157
s.ann.nested(s, Nested::BodyParamPat(body_id, i));
21562158
s.word(":");

tests/pretty/hir-fn-params.pp

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
// because they had similar problems. But the pretty-printing tests currently
2828
// can't contain compile errors.
2929
30-
fn bare_fn(x: fn(: u32, _: u32, a: u32)) { }
30+
fn bare_fn(x: fn(u32, _: u32, a: u32)) { }
3131
3232
extern "C" {
3333
unsafe fn foreign_fn(_: u32, a: u32);
3434
}
3535
3636
trait T {
37-
fn trait_fn(: u32, _: u32, a: u32);
37+
fn trait_fn(u32, _: u32, a: u32);
3838
}

0 commit comments

Comments
 (0)