Skip to content

Commit bcefc2e

Browse files
committed
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.
1 parent ec7c026 commit bcefc2e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

compiler/rustc_borrowck/src/region_infer/graphviz.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,21 @@ fn render_region_vid<'tcx>(
4141
"".to_string()
4242
};
4343

44-
format!("{:?}{universe_str}{external_name_str}", rvid)
44+
let extra_info = match regioncx.region_definition(rvid).origin {
45+
NllRegionVariableOrigin::FreeRegion => "".to_string(),
46+
NllRegionVariableOrigin::Placeholder(p) => match p.bound.kind {
47+
ty::BoundRegionKind::Named(def_id) => {
48+
format!("(p for {})", tcx.item_name(def_id))
49+
}
50+
ty::BoundRegionKind::ClosureEnv | ty::BoundRegionKind::Anon => "(p)".to_string(),
51+
ty::BoundRegionKind::NamedAnon(_) => {
52+
bug!("only used for pretty printing")
53+
}
54+
},
55+
NllRegionVariableOrigin::Existential { .. } => "(ex)".to_string(),
56+
};
57+
58+
format!("{:?}{universe_str}{external_name_str}{extra_info}", rvid)
4559
}
4660

4761
impl<'tcx> RegionInferenceContext<'tcx> {

0 commit comments

Comments
 (0)