From 504ea670ae35098da3b418e0a1e6cd963d699d2c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 5 Feb 2025 18:25:33 +0100 Subject: [PATCH] Add `rustc_hir_pretty::expr_to_string` function --- compiler/rustc_hir_pretty/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 3b163d0bc2050..8efef0c612b0d 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -321,6 +321,10 @@ pub fn pat_to_string(ann: &dyn PpAnn, pat: &hir::Pat<'_>) -> String { to_string(ann, |s| s.print_pat(pat)) } +pub fn expr_to_string(ann: &dyn PpAnn, pat: &hir::Expr<'_>) -> String { + to_string(ann, |s| s.print_expr(pat)) +} + impl<'a> State<'a> { fn bclose_maybe_open(&mut self, span: rustc_span::Span, close_box: bool) { self.maybe_print_comment(span.hi());