mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 21:28:51 +00:00
Merge pull request #18708 from ChayimFriedman2/fix-tiny
fix: Fix pretty-printing of `@` patterns
This commit is contained in:
commit
2780dfd80c
2 changed files with 19 additions and 0 deletions
|
@ -685,6 +685,7 @@ impl Printer<'_> {
|
||||||
self.print_binding(*id);
|
self.print_binding(*id);
|
||||||
if let Some(pat) = subpat {
|
if let Some(pat) = subpat {
|
||||||
self.whitespace();
|
self.whitespace();
|
||||||
|
w!(self, "@ ");
|
||||||
self.print_pat(*pat);
|
self.print_pat(*pat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -426,3 +426,21 @@ fn f() {
|
||||||
"should have a binding for `B`",
|
"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;
|
||||||
|
}"#
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue