diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-03-14 07:29:19 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-03-14 09:45:41 +1100 |
| commit | bebd91feb32667b6a1bb7a11da91ab8a935b4c24 (patch) | |
| tree | 0314e077b348e0a16c65c6ed68d6cdf822cac365 | |
| parent | 958bc7b3655a0880361b11f9052fab84030cde26 (diff) | |
| download | rust-bebd91feb32667b6a1bb7a11da91ab8a935b4c24.tar.gz rust-bebd91feb32667b6a1bb7a11da91ab8a935b4c24.zip | |
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`.)
| -rw-r--r-- | compiler/rustc_hir_pretty/src/lib.rs | 8 | ||||
| -rw-r--r-- | tests/pretty/hir-fn-params.pp | 4 |
2 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 3067766fb4d..1409310339a 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -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) { - s.word(arg_name.to_string()); - s.word(":"); - s.space(); + 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(":"); diff --git a/tests/pretty/hir-fn-params.pp b/tests/pretty/hir-fn-params.pp index f33e26b7e8c..3799c8a3c3b 100644 --- a/tests/pretty/hir-fn-params.pp +++ b/tests/pretty/hir-fn-params.pp @@ -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); } |
