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 <name>) 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.
This commit is contained in:
Amanda Stjerna 2025-08-06 11:12:51 +02:00
parent ec7c026125
commit bcefc2ee97

View file

@ -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> {