Fix pretty-printing of @ patterns

It didn't print the `@`.
This commit is contained in:
Chayim Refael Friedman 2024-12-18 01:24:12 +02:00
parent 27e824fad4
commit 8c8e738636
2 changed files with 19 additions and 0 deletions

View file

@ -685,6 +685,7 @@ impl Printer<'_> {
self.print_binding(*id);
if let Some(pat) = subpat {
self.whitespace();
w!(self, "@ ");
self.print_pat(*pat);
}
}

View file

@ -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;
}"#
);
}