Skip to content

Commit 9a34822

Browse files
committed
replace universal_region with adding entries to region_live_at
There aren't that many universal regions. This was a premature optimization and it makes the code much messier.
1 parent 9d40370 commit 9a34822

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/librustc_mir/borrow_check/location.rs

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec};
2323
/// table serves another purpose: it compresses locations from
2424
/// multiple words into a single u32.
2525
crate struct LocationTable {
26+
num_points: usize,
2627
statements_before_block: IndexVec<BasicBlock, usize>,
2728
}
2829

@@ -53,10 +54,15 @@ impl LocationTable {
5354
debug!("LocationTable: num_points={:#?}", num_points);
5455

5556
Self {
57+
num_points,
5658
statements_before_block,
5759
}
5860
}
5961

62+
crate fn all_points(&self) -> impl Iterator<Item = LocationIndex> {
63+
(0..self.num_points).map(LocationIndex::new)
64+
}
65+
6066
crate fn start_index(&self, location: Location) -> LocationIndex {
6167
let Location {
6268
block,

src/librustc_mir/borrow_check/nll/mod.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,14 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
111111
};
112112

113113
if let Some(all_facts) = &mut all_facts {
114-
all_facts
115-
.universal_region
116-
.extend(universal_regions.universal_regions());
114+
// Declare that each universal region is live at every point.
115+
for ur in universal_regions.universal_regions() {
116+
all_facts.region_live_at.extend(
117+
location_table
118+
.all_points()
119+
.map(|p| (ur, p))
120+
);
121+
}
117122
}
118123

119124
// Create the region inference context, taking ownership of the region inference

0 commit comments

Comments
 (0)