1
Fork 0

Add check that region is live in sanitize_promoted

This commit is contained in:
Noble-Mushtak 2021-09-08 21:30:22 -04:00
parent ca8078d7b2
commit 8fc329f5d2
7 changed files with 83 additions and 16 deletions

View file

@ -2154,7 +2154,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
// appears to be the most interesting point to report to the
// user via an even more ad-hoc guess.
categorized_path.sort_by(|p0, p1| p0.category.cmp(&p1.category));
debug!("`: sorted_path={:#?}", categorized_path);
debug!("best_blame_constraint: sorted_path={:#?}", categorized_path);
categorized_path.remove(0)
}

View file

@ -174,17 +174,19 @@ impl<N: Idx> LivenessValues<N> {
self.points.contains(row, index)
}
/// Returns an iterator of all the elements contained by the region `r`
crate fn get_elements(&self, row: N) -> impl Iterator<Item = Location> + '_ {
self.points
.row(row)
.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))
}
/// Returns a "pretty" string value of the region. Meant for debugging.
crate fn region_value_str(&self, r: N) -> String {
region_value_str(
self.points
.row(r)
.into_iter()
.flat_map(|set| set.iter())
.take_while(|&p| self.elements.point_in_range(p))
.map(|p| self.elements.to_location(p))
.map(RegionElement::Location),
)
region_value_str(self.get_elements(r).map(RegionElement::Location))
}
}

View file

@ -663,12 +663,17 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
}
self.cx.borrowck_context.constraints.outlives_constraints.push(constraint)
}
for live_region in liveness_constraints.rows() {
self.cx
.borrowck_context
.constraints
.liveness_constraints
.add_element(live_region, location);
for region in liveness_constraints.rows() {
// 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 let Some(_) = liveness_constraints.get_elements(region).next() {
self.cx
.borrowck_context
.constraints
.liveness_constraints
.add_element(region, location);
}
}
if !closure_bounds.is_empty() {