Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8ac459b

Browse files
authoredJan 11, 2025··
Unrolled build for rust-lang#135205
Rollup merge of rust-lang#135205 - lqd:bitsets, r=Mark-Simulacrum Rename `BitSet` to `DenseBitSet` r? `@Mark-Simulacrum` as you requested this in rust-lang#134438 (comment) after such a confusion. This PR renames `BitSet` to `DenseBitSet` to make it less obvious as the go-to solution for bitmap needs, as well as make its representation (and positives/negatives) clearer. It also expands the comments there to hopefully make it clearer when it's not a good fit, with some alternative bitsets types. (This migrates the subtrees cg_gcc and clippy to use the new name in separate commits, for easier review by their respective owners, but they can obvs be squashed)
2 parents fb65a3e + 95cbb3b commit 8ac459b

File tree

73 files changed

+397
-380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+397
-380
lines changed
 

‎compiler/rustc_borrowck/src/borrow_set.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::fmt;
22
use std::ops::Index;
33

44
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
5-
use rustc_index::bit_set::BitSet;
5+
use rustc_index::bit_set::DenseBitSet;
66
use rustc_middle::mir::visit::{MutatingUseContext, NonUseContext, PlaceContext, Visitor};
77
use rustc_middle::mir::{self, Body, Local, Location, traversal};
88
use rustc_middle::span_bug;
@@ -131,7 +131,7 @@ impl<'tcx> fmt::Display for BorrowData<'tcx> {
131131

132132
pub enum LocalsStateAtExit {
133133
AllAreInvalidated,
134-
SomeAreInvalidated { has_storage_dead_or_moved: BitSet<Local> },
134+
SomeAreInvalidated { has_storage_dead_or_moved: DenseBitSet<Local> },
135135
}
136136

137137
impl LocalsStateAtExit {
@@ -140,7 +140,7 @@ impl LocalsStateAtExit {
140140
body: &Body<'tcx>,
141141
move_data: &MoveData<'tcx>,
142142
) -> Self {
143-
struct HasStorageDead(BitSet<Local>);
143+
struct HasStorageDead(DenseBitSet<Local>);
144144

145145
impl<'tcx> Visitor<'tcx> for HasStorageDead {
146146
fn visit_local(&mut self, local: Local, ctx: PlaceContext, _: Location) {
@@ -153,7 +153,8 @@ impl LocalsStateAtExit {
153153
if locals_are_invalidated_at_exit {
154154
LocalsStateAtExit::AllAreInvalidated
155155
} else {
156-
let mut has_storage_dead = HasStorageDead(BitSet::new_empty(body.local_decls.len()));
156+
let mut has_storage_dead =
157+
HasStorageDead(DenseBitSet::new_empty(body.local_decls.len()));
157158
has_storage_dead.visit_body(body);
158159
let mut has_storage_dead_or_moved = has_storage_dead.0;
159160
for move_out in &move_data.moves {

‎compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::fmt;
22

33
use rustc_data_structures::fx::FxIndexMap;
44
use rustc_data_structures::graph;
5-
use rustc_index::bit_set::BitSet;
5+
use rustc_index::bit_set::DenseBitSet;
66
use rustc_middle::mir::{
77
self, BasicBlock, Body, CallReturnPlaces, Location, Place, TerminatorEdges,
88
};
@@ -180,7 +180,7 @@ pub struct Borrows<'a, 'tcx> {
180180
}
181181

182182
struct OutOfScopePrecomputer<'a, 'tcx> {
183-
visited: BitSet<mir::BasicBlock>,
183+
visited: DenseBitSet<mir::BasicBlock>,
184184
visit_stack: Vec<mir::BasicBlock>,
185185
body: &'a Body<'tcx>,
186186
regioncx: &'a RegionInferenceContext<'tcx>,
@@ -190,7 +190,7 @@ struct OutOfScopePrecomputer<'a, 'tcx> {
190190
impl<'a, 'tcx> OutOfScopePrecomputer<'a, 'tcx> {
191191
fn new(body: &'a Body<'tcx>, regioncx: &'a RegionInferenceContext<'tcx>) -> Self {
192192
OutOfScopePrecomputer {
193-
visited: BitSet::new_empty(body.basic_blocks.len()),
193+
visited: DenseBitSet::new_empty(body.basic_blocks.len()),
194194
visit_stack: vec![],
195195
body,
196196
regioncx,
@@ -292,7 +292,7 @@ pub fn calculate_borrows_out_of_scope_at_location<'tcx>(
292292
}
293293

294294
struct PoloniusOutOfScopePrecomputer<'a, 'tcx> {
295-
visited: BitSet<mir::BasicBlock>,
295+
visited: DenseBitSet<mir::BasicBlock>,
296296
visit_stack: Vec<mir::BasicBlock>,
297297
body: &'a Body<'tcx>,
298298
regioncx: &'a RegionInferenceContext<'tcx>,
@@ -303,7 +303,7 @@ struct PoloniusOutOfScopePrecomputer<'a, 'tcx> {
303303
impl<'a, 'tcx> PoloniusOutOfScopePrecomputer<'a, 'tcx> {
304304
fn new(body: &'a Body<'tcx>, regioncx: &'a RegionInferenceContext<'tcx>) -> Self {
305305
Self {
306-
visited: BitSet::new_empty(body.basic_blocks.len()),
306+
visited: DenseBitSet::new_empty(body.basic_blocks.len()),
307307
visit_stack: vec![],
308308
body,
309309
regioncx,
@@ -559,7 +559,7 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
559559
}
560560
}
561561

562-
type BorrowsDomain = BitSet<BorrowIndex>;
562+
type BorrowsDomain = DenseBitSet<BorrowIndex>;
563563

564564
/// Forward dataflow computation of the set of borrows that are in scope at a particular location.
565565
/// - we gen the introduced loans
@@ -575,7 +575,7 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
575575

576576
fn bottom_value(&self, _: &mir::Body<'tcx>) -> Self::Domain {
577577
// bottom = nothing is reserved or activated yet;
578-
BitSet::new_empty(self.borrow_set.len())
578+
DenseBitSet::new_empty(self.borrow_set.len())
579579
}
580580

581581
fn initialize_start_block(&self, _: &mir::Body<'tcx>, _: &mut Self::Domain) {

0 commit comments

Comments
 (0)
This repository has been archived.