Skip to content

Commit 45f3da5

Browse files
authored
Merge pull request rust-lang#18708 from ChayimFriedman2/fix-tiny
fix: Fix pretty-printing of `@` patterns
2 parents 7f45fed + 716673c commit 45f3da5

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Diff for: src/tools/rust-analyzer/crates/hir-def/src/body/pretty.rs

+1
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ impl Printer<'_> {
685685
self.print_binding(*id);
686686
if let Some(pat) = subpat {
687687
self.whitespace();
688+
w!(self, "@ ");
688689
self.print_pat(*pat);
689690
}
690691
}

Diff for: src/tools/rust-analyzer/crates/hir-def/src/body/tests.rs

+18
Original file line numberDiff line numberDiff line change
@@ -426,3 +426,21 @@ fn f() {
426426
"should have a binding for `B`",
427427
);
428428
}
429+
430+
#[test]
431+
fn regression_pretty_print_bind_pat() {
432+
let (db, body, owner) = lower(
433+
r#"
434+
fn foo() {
435+
let v @ u = 123;
436+
}
437+
"#,
438+
);
439+
let printed = body.pretty_print(&db, owner, Edition::CURRENT);
440+
assert_eq!(
441+
printed,
442+
r#"fn foo() -> () {
443+
let v @ u = 123;
444+
}"#
445+
);
446+
}

0 commit comments

Comments
 (0)