From 8c8e7386368b50e7cf8e9fd731735de846e1103e Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Wed, 18 Dec 2024 01:24:12 +0200 Subject: [PATCH] Fix pretty-printing of `@` patterns It didn't print the `@`. --- crates/hir-def/src/body/pretty.rs | 1 + crates/hir-def/src/body/tests.rs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/crates/hir-def/src/body/pretty.rs b/crates/hir-def/src/body/pretty.rs index f8b6eef342..52b91b522a 100644 --- a/crates/hir-def/src/body/pretty.rs +++ b/crates/hir-def/src/body/pretty.rs @@ -685,6 +685,7 @@ impl Printer<'_> { self.print_binding(*id); if let Some(pat) = subpat { self.whitespace(); + w!(self, "@ "); self.print_pat(*pat); } } diff --git a/crates/hir-def/src/body/tests.rs b/crates/hir-def/src/body/tests.rs index 8f01091584..13ba4db606 100644 --- a/crates/hir-def/src/body/tests.rs +++ b/crates/hir-def/src/body/tests.rs @@ -426,3 +426,21 @@ fn f() { "should have a binding for `B`", ); } + +#[test] +fn regression_pretty_print_bind_pat() { + let (db, body, owner) = lower( + r#" +fn foo() { + let v @ u = 123; +} +"#, + ); + let printed = body.pretty_print(&db, owner, Edition::CURRENT); + assert_eq!( + printed, + r#"fn foo() -> () { + let v @ u = 123; +}"# + ); +}