diff options
| author | Rémy Rakic <remy.rakic+github@gmail.com> | 2023-11-13 15:28:26 +0000 |
|---|---|---|
| committer | Rémy Rakic <remy.rakic+github@gmail.com> | 2023-11-14 11:22:13 +0000 |
| commit | 84a002cc4299b387a5f4b234f50155f8ea3c900d (patch) | |
| tree | 89168fd7d2807ceac32762eddf698103fac03f51 | |
| parent | 79c5e913d3de11566cf60fa1d069141639ee913f (diff) | |
| download | rust-84a002cc4299b387a5f4b234f50155f8ea3c900d.tar.gz rust-84a002cc4299b387a5f4b234f50155f8ea3c900d.zip | |
`LivenessValues` does not need to be generic over regions
4 files changed, 18 insertions, 18 deletions
diff --git a/compiler/rustc_borrowck/src/constraint_generation.rs b/compiler/rustc_borrowck/src/constraint_generation.rs index 02b3bed94bf..21d367c40cb 100644 --- a/compiler/rustc_borrowck/src/constraint_generation.rs +++ b/compiler/rustc_borrowck/src/constraint_generation.rs @@ -9,7 +9,7 @@ use rustc_middle::mir::{ }; use rustc_middle::ty::visit::TypeVisitable; use rustc_middle::ty::GenericArgsRef; -use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt}; +use rustc_middle::ty::{self, Ty, TyCtxt}; use crate::{ borrow_set::BorrowSet, facts::AllFacts, location::LocationTable, places_conflict, @@ -18,7 +18,7 @@ use crate::{ pub(super) fn generate_constraints<'tcx>( infcx: &InferCtxt<'tcx>, - liveness_constraints: &mut LivenessValues<RegionVid>, + liveness_constraints: &mut LivenessValues, all_facts: &mut Option<AllFacts>, location_table: &LocationTable, body: &Body<'tcx>, @@ -43,7 +43,7 @@ struct ConstraintGeneration<'cg, 'tcx> { infcx: &'cg InferCtxt<'tcx>, all_facts: &'cg mut Option<AllFacts>, location_table: &'cg LocationTable, - liveness_constraints: &'cg mut LivenessValues<RegionVid>, + liveness_constraints: &'cg mut LivenessValues, borrow_set: &'cg BorrowSet<'tcx>, body: &'cg Body<'tcx>, } diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index b9a824c1401..ff125a02745 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -59,7 +59,7 @@ pub struct RegionInferenceContext<'tcx> { /// regions, these start out empty and steadily grow, though for /// each universally quantified region R they start out containing /// the entire CFG and `end(R)`. - liveness_constraints: LivenessValues<RegionVid>, + liveness_constraints: LivenessValues, /// The outlives constraints computed by the type-check. constraints: Frozen<OutlivesConstraintSet<'tcx>>, @@ -332,7 +332,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { member_constraints_in: MemberConstraintSet<'tcx, RegionVid>, universe_causes: FxIndexMap<ty::UniverseIndex, UniverseInfo<'tcx>>, type_tests: Vec<TypeTest<'tcx>>, - liveness_constraints: LivenessValues<RegionVid>, + liveness_constraints: LivenessValues, elements: &Rc<RegionValueElements>, live_loans: SparseBitMatrix<PointIndex, BorrowIndex>, ) -> Self { diff --git a/compiler/rustc_borrowck/src/region_infer/values.rs b/compiler/rustc_borrowck/src/region_infer/values.rs index d0e24f7817a..e73872bf66a 100644 --- a/compiler/rustc_borrowck/src/region_infer/values.rs +++ b/compiler/rustc_borrowck/src/region_infer/values.rs @@ -118,53 +118,53 @@ pub(crate) enum RegionElement { /// Records the CFG locations where each region is live. When we initially compute liveness, we use /// an interval matrix storing liveness ranges for each region-vid. -pub(crate) struct LivenessValues<N: Idx> { +pub(crate) struct LivenessValues { elements: Rc<RegionValueElements>, - points: SparseIntervalMatrix<N, PointIndex>, + points: SparseIntervalMatrix<RegionVid, PointIndex>, } -impl<N: Idx> LivenessValues<N> { +impl LivenessValues { /// Create an empty map of regions to locations where they're live. pub(crate) fn new(elements: Rc<RegionValueElements>) -> Self { Self { points: SparseIntervalMatrix::new(elements.num_points), elements } } /// Iterate through each region that has a value in this set. - pub(crate) fn regions(&self) -> impl Iterator<Item = N> { + pub(crate) fn regions(&self) -> impl Iterator<Item = RegionVid> { self.points.rows() } /// Records `region` as being live at the given `location`. - pub(crate) fn add_location(&mut self, region: N, location: Location) { + pub(crate) fn add_location(&mut self, region: RegionVid, location: Location) { debug!("LivenessValues::add_location(region={:?}, location={:?})", region, location); let point = self.elements.point_from_location(location); self.points.insert(region, point); } /// Records `region` as being live at all the given `points`. - pub(crate) fn add_points(&mut self, region: N, points: &IntervalSet<PointIndex>) { + pub(crate) fn add_points(&mut self, region: RegionVid, points: &IntervalSet<PointIndex>) { debug!("LivenessValues::add_points(region={:?}, points={:?})", region, points); self.points.union_row(region, points); } /// Records `region` as being live at all the control-flow points. - pub(crate) fn add_all_points(&mut self, region: N) { + pub(crate) fn add_all_points(&mut self, region: RegionVid) { self.points.insert_all_into_row(region); } /// Returns whether `region` is marked live at the given `location`. - pub(crate) fn is_live_at(&self, region: N, location: Location) -> bool { + pub(crate) fn is_live_at(&self, region: RegionVid, location: Location) -> bool { let point = self.elements.point_from_location(location); self.points.row(region).is_some_and(|r| r.contains(point)) } /// Returns whether `region` is marked live at any location. - pub(crate) fn is_live_anywhere(&self, region: N) -> bool { + pub(crate) fn is_live_anywhere(&self, region: RegionVid) -> 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> + '_ { + fn live_points(&self, region: RegionVid) -> impl Iterator<Item = PointIndex> + '_ { self.points .row(region) .into_iter() @@ -173,7 +173,7 @@ impl<N: Idx> LivenessValues<N> { } /// Returns a "pretty" string value of the region. Meant for debugging. - pub(crate) fn region_value_str(&self, region: N) -> String { + pub(crate) fn region_value_str(&self, region: RegionVid) -> String { region_value_str( self.live_points(region).map(|p| RegionElement::Location(self.elements.to_location(p))), ) @@ -309,7 +309,7 @@ impl<N: Idx> RegionValues<N> { /// `self[to] |= values[from]`, essentially: that is, take all the /// elements for the region `from` from `values` and add them to /// the region `to` in `self`. - pub(crate) fn merge_liveness<M: Idx>(&mut self, to: N, from: M, values: &LivenessValues<M>) { + pub(crate) fn merge_liveness(&mut self, to: N, from: RegionVid, values: &LivenessValues) { if let Some(set) = values.points.row(from) { self.points.union_row(to, set); } diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index e23f633bea2..f0e35bdb75f 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -899,7 +899,7 @@ pub(crate) struct MirTypeckRegionConstraints<'tcx> { /// not otherwise appear in the MIR -- in particular, the /// late-bound regions that it instantiates at call-sites -- and /// hence it must report on their liveness constraints. - pub(crate) liveness_constraints: LivenessValues<RegionVid>, + pub(crate) liveness_constraints: LivenessValues, pub(crate) outlives_constraints: OutlivesConstraintSet<'tcx>, |
