1
Fork 0

Fix pretty hir for anon consts in diagnostics

This commit is contained in:
Michael Goulet 2024-04-14 10:26:59 -04:00
parent 3493a56529
commit 619e044178
13 changed files with 32 additions and 41 deletions

View file

@ -49,10 +49,6 @@ pub trait PpAnn {
fn post(&self, _state: &mut State<'_>, _node: AnnNode<'_>) {}
}
pub struct NoAnn;
impl PpAnn for NoAnn {}
impl PpAnn for &dyn rustc_hir::intravisit::Map<'_> {
fn nested(&self, state: &mut State<'_>, nested: Nested) {
match nested {
@ -190,16 +186,16 @@ where
printer.s.eof()
}
pub fn ty_to_string(ty: &hir::Ty<'_>) -> String {
to_string(&NoAnn, |s| s.print_type(ty))
pub fn ty_to_string(ann: &dyn PpAnn, ty: &hir::Ty<'_>) -> String {
to_string(ann, |s| s.print_type(ty))
}
pub fn qpath_to_string(segment: &hir::QPath<'_>) -> String {
to_string(&NoAnn, |s| s.print_qpath(segment, false))
pub fn qpath_to_string(ann: &dyn PpAnn, segment: &hir::QPath<'_>) -> String {
to_string(ann, |s| s.print_qpath(segment, false))
}
pub fn pat_to_string(pat: &hir::Pat<'_>) -> String {
to_string(&NoAnn, |s| s.print_pat(pat))
pub fn pat_to_string(ann: &dyn PpAnn, pat: &hir::Pat<'_>) -> String {
to_string(ann, |s| s.print_pat(pat))
}
impl<'a> State<'a> {