introduce is_live_anywhere
instead of peeking into points
and refactor misnamed `get_elements`
This commit is contained in:
parent
b4c7d1dd05
commit
79c5e913d3
@ -158,19 +158,25 @@ impl<N: Idx> LivenessValues<N> {
|
||||
self.points.row(region).is_some_and(|r| r.contains(point))
|
||||
}
|
||||
|
||||
/// Returns an iterator of all the elements contained by `region`.
|
||||
pub(crate) fn get_elements(&self, region: N) -> impl Iterator<Item = Location> + '_ {
|
||||
/// Returns whether `region` is marked live at any location.
|
||||
pub(crate) fn is_live_anywhere(&self, region: N) -> bool {
|
||||
self.live_points(region).next().is_some()
|
||||
}
|
||||
|
||||
/// Returns an iterator of all the points where `region` is live.
|
||||
fn live_points(&self, region: N) -> impl Iterator<Item = PointIndex> + '_ {
|
||||
self.points
|
||||
.row(region)
|
||||
.into_iter()
|
||||
.flat_map(|set| set.iter())
|
||||
.take_while(move |&p| self.elements.point_in_range(p))
|
||||
.map(move |p| self.elements.to_location(p))
|
||||
.take_while(|&p| self.elements.point_in_range(p))
|
||||
}
|
||||
|
||||
/// Returns a "pretty" string value of the region. Meant for debugging.
|
||||
pub(crate) fn region_value_str(&self, region: N) -> String {
|
||||
region_value_str(self.get_elements(region).map(RegionElement::Location))
|
||||
region_value_str(
|
||||
self.live_points(region).map(|p| RegionElement::Location(self.elements.to_location(p))),
|
||||
)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -596,7 +596,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
|
||||
// If the region is live at at least one location in the promoted MIR,
|
||||
// then add a liveness constraint to the main MIR for this region
|
||||
// at the location provided as an argument to this method
|
||||
if liveness_constraints.get_elements(region).next().is_some() {
|
||||
if liveness_constraints.is_live_anywhere(region) {
|
||||
self.cx
|
||||
.borrowck_context
|
||||
.constraints
|
||||
|
Loading…
x
Reference in New Issue
Block a user