diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2024-12-18 07:41:09 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-18 07:41:09 +0000 |
| commit | 45f3da589ced87c0a6b18e5c1b3d90ee84700eb8 (patch) | |
| tree | 373264d5e4b25515b5506f3525a72fd186a44e5a | |
| parent | 7f45fedec505a256d91076c083ff8a6b32236687 (diff) | |
| parent | 716673ce9f6ba91bcdf6c9620ac5aaa3eb0473c1 (diff) | |
| download | rust-45f3da589ced87c0a6b18e5c1b3d90ee84700eb8.tar.gz rust-45f3da589ced87c0a6b18e5c1b3d90ee84700eb8.zip | |
Merge pull request #18708 from ChayimFriedman2/fix-tiny
fix: Fix pretty-printing of `@` patterns
| -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; +}"# + ); +} |
