From bcefc2ee977e38a4a5ecd0956e19b0968d33052b Mon Sep 17 00:00:00 2001 From: Amanda Stjerna Date: Wed, 6 Aug 2025 11:12:51 +0200 Subject: [PATCH] Add annotations to the graphviz region graph on region origins This adds - (ex) for regions whose origin is existential, - (p) for regoins whose origin is a placeholder, and - (p for ) if the originating placeholder is named. This has helped _my_ debugging and it doesn't create too bad clutter, I feel. The change is ridiculously small, but I turned it into a separate PR so we can bikeshed the format. --- .../rustc_borrowck/src/region_infer/graphviz.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_borrowck/src/region_infer/graphviz.rs b/compiler/rustc_borrowck/src/region_infer/graphviz.rs index a3e29982e90f..899dde9ecd47 100644 --- a/compiler/rustc_borrowck/src/region_infer/graphviz.rs +++ b/compiler/rustc_borrowck/src/region_infer/graphviz.rs @@ -41,7 +41,21 @@ fn render_region_vid<'tcx>( "".to_string() }; - format!("{:?}{universe_str}{external_name_str}", rvid) + let extra_info = match regioncx.region_definition(rvid).origin { + NllRegionVariableOrigin::FreeRegion => "".to_string(), + NllRegionVariableOrigin::Placeholder(p) => match p.bound.kind { + ty::BoundRegionKind::Named(def_id) => { + format!("(p for {})", tcx.item_name(def_id)) + } + ty::BoundRegionKind::ClosureEnv | ty::BoundRegionKind::Anon => "(p)".to_string(), + ty::BoundRegionKind::NamedAnon(_) => { + bug!("only used for pretty printing") + } + }, + NllRegionVariableOrigin::Existential { .. } => "(ex)".to_string(), + }; + + format!("{:?}{universe_str}{external_name_str}{extra_info}", rvid) } impl<'tcx> RegionInferenceContext<'tcx> {