Skip to content

Commit

Permalink
rename debugging support functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lqd committed Nov 13, 2023
1 parent aa481bd commit 3abf0e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions compiler/rustc_borrowck/src/region_infer/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ impl LivenessValues {
.take_while(move |&p| self.elements.point_in_range(p))
}

/// Returns a "pretty" string value of the region. Meant for debugging.
/// For debugging purposes, returns a pretty-printed string of the points where the `region` is
/// live.
pub(crate) fn region_value_str(&self, region: RegionVid) -> String {
region_value_str(
pretty_print_region_elements(
self.live_points(region).map(|p| RegionElement::Location(self.elements.to_location(p))),
)
}
Expand Down Expand Up @@ -378,7 +379,7 @@ impl<N: Idx> RegionValues<N> {

/// Returns a "pretty" string value of the region. Meant for debugging.
pub(crate) fn region_value_str(&self, r: N) -> String {
region_value_str(self.elements_contained_in(r))
pretty_print_region_elements(self.elements_contained_in(r))
}
}

Expand Down Expand Up @@ -422,11 +423,12 @@ impl ToElementIndex for ty::PlaceholderRegion {
}
}

pub(crate) fn location_set_str(
/// For debugging purposes, returns a pretty-printed string of the given points.
pub(crate) fn pretty_print_points(
elements: &RegionValueElements,
points: impl IntoIterator<Item = PointIndex>,
) -> String {
region_value_str(
pretty_print_region_elements(
points
.into_iter()
.take_while(|&p| elements.point_in_range(p))
Expand All @@ -435,7 +437,8 @@ pub(crate) fn location_set_str(
)
}

fn region_value_str(elements: impl IntoIterator<Item = RegionElement>) -> String {
/// For debugging purposes, returns a pretty-printed string of the given region elements.
fn pretty_print_region_elements(elements: impl IntoIterator<Item = RegionElement>) -> String {
let mut result = String::new();
result.push('{');

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/type_check/liveness/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
dropped_local,
dropped_ty,
drop_locations,
values::location_set_str(self.elements, live_at.iter()),
values::pretty_print_points(self.elements, live_at.iter()),
);

let drop_data = self.drop_data.entry(dropped_ty).or_insert_with({
Expand Down Expand Up @@ -599,7 +599,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
debug!("make_all_regions_live(value={:?})", value);
debug!(
"make_all_regions_live: live_at={}",
values::location_set_str(elements, live_at.iter()),
values::pretty_print_points(elements, live_at.iter()),
);

// When using `-Zpolonius=next`, we want to record the loans that flow into this value's
Expand Down

0 comments on commit 3abf0e3

Please sign in to comment.