diff options
| author | Chayim Refael Friedman <chayimfr@gmail.com> | 2024-12-18 01:24:12 +0200 |
|---|---|---|
| committer | Chayim Refael Friedman <chayimfr@gmail.com> | 2024-12-18 01:24:12 +0200 |
| commit | 716673ce9f6ba91bcdf6c9620ac5aaa3eb0473c1 (patch) | |
| tree | d10f66a051525edc9c9c07b9a654ac16f2a379c8 /src/tools | |
| parent | 5c6bae0fc0930d57dba2e279c0b67a4397b3999c (diff) | |
| download | rust-716673ce9f6ba91bcdf6c9620ac5aaa3eb0473c1.tar.gz rust-716673ce9f6ba91bcdf6c9620ac5aaa3eb0473c1.zip | |
Fix pretty-printing of `@` patterns
It didn't print the `@`.
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/rust-analyzer/crates/hir-def/src/body/pretty.rs | 1 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/crates/hir-def/src/body/tests.rs | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-def/src/body/pretty.rs b/src/tools/rust-analyzer/crates/hir-def/src/body/pretty.rs index f8b6eef3422..52b91b522a4 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/body/pretty.rs +++ b/src/tools/rust-analyzer/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/src/tools/rust-analyzer/crates/hir-def/src/body/tests.rs b/src/tools/rust-analyzer/crates/hir-def/src/body/tests.rs index 8f010915845..13ba4db6064 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/body/tests.rs +++ b/src/tools/rust-analyzer/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; +}"# + ); +} |
