@@ -7,7 +7,7 @@ use rustc_data_structures::unord::{UnordMap, UnordSet};
7
7
use rustc_errors:: Subdiagnostic ;
8
8
use rustc_hir:: CRATE_HIR_ID ;
9
9
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
10
- use rustc_index:: bit_set:: ChunkedBitSet ;
10
+ use rustc_index:: bit_set:: MixedBitSet ;
11
11
use rustc_index:: { IndexSlice , IndexVec } ;
12
12
use rustc_macros:: { LintDiagnostic , Subdiagnostic } ;
13
13
use rustc_middle:: bug;
@@ -49,24 +49,24 @@ struct DropsReachable<'a, 'mir, 'tcx> {
49
49
move_data : & ' a MoveData < ' tcx > ,
50
50
maybe_init : & ' a mut ResultsCursor < ' mir , ' tcx , MaybeInitializedPlaces < ' mir , ' tcx > > ,
51
51
block_drop_value_info : & ' a mut IndexSlice < BasicBlock , MovePathIndexAtBlock > ,
52
- collected_drops : & ' a mut ChunkedBitSet < MovePathIndex > ,
53
- visited : FxHashMap < BasicBlock , Rc < RefCell < ChunkedBitSet < MovePathIndex > > > > ,
52
+ collected_drops : & ' a mut MixedBitSet < MovePathIndex > ,
53
+ visited : FxHashMap < BasicBlock , Rc < RefCell < MixedBitSet < MovePathIndex > > > > ,
54
54
}
55
55
56
56
impl < ' a , ' mir , ' tcx > DropsReachable < ' a , ' mir , ' tcx > {
57
57
fn visit ( & mut self , block : BasicBlock ) {
58
58
let move_set_size = self . move_data . move_paths . len ( ) ;
59
- let make_new_path_set = || Rc :: new ( RefCell :: new ( ChunkedBitSet :: new_empty ( move_set_size) ) ) ;
59
+ let make_new_path_set = || Rc :: new ( RefCell :: new ( MixedBitSet :: new_empty ( move_set_size) ) ) ;
60
60
61
61
let data = & self . body . basic_blocks [ block] ;
62
62
let Some ( terminator) = & data. terminator else { return } ;
63
- // Given that we observe these dropped locals here at `block` so far,
64
- // we will try to update the successor blocks.
65
- // An occupied entry at `block` in `self.visited` signals that we have visited `block` before.
63
+ // Given that we observe these dropped locals here at `block` so far, we will try to update
64
+ // the successor blocks. An occupied entry at `block` in `self.visited` signals that we
65
+ // have visited `block` before.
66
66
let dropped_local_here =
67
67
Rc :: clone ( self . visited . entry ( block) . or_insert_with ( make_new_path_set) ) ;
68
- // We could have invoked reverse lookup for a `MovePathIndex` every time, but unfortunately it is expensive.
69
- // Let's cache them in `self.block_drop_value_info`.
68
+ // We could have invoked reverse lookup for a `MovePathIndex` every time, but unfortunately
69
+ // it is expensive. Let's cache them in `self.block_drop_value_info`.
70
70
match self . block_drop_value_info [ block] {
71
71
MovePathIndexAtBlock :: Some ( dropped) => {
72
72
dropped_local_here. borrow_mut ( ) . insert ( dropped) ;
@@ -76,23 +76,24 @@ impl<'a, 'mir, 'tcx> DropsReachable<'a, 'mir, 'tcx> {
76
76
&& let LookupResult :: Exact ( idx) | LookupResult :: Parent ( Some ( idx) ) =
77
77
self . move_data . rev_lookup . find ( place. as_ref ( ) )
78
78
{
79
- // Since we are working with MIRs at a very early stage,
80
- // observing a `drop` terminator is not indicative enough that
81
- // the drop will definitely happen.
82
- // That is decided in the drop elaboration pass instead.
83
- // Therefore, we need to consult with the maybe-initialization information.
79
+ // Since we are working with MIRs at a very early stage, observing a `drop`
80
+ // terminator is not indicative enough that the drop will definitely happen.
81
+ // That is decided in the drop elaboration pass instead. Therefore, we need to
82
+ // consult with the maybe-initialization information.
84
83
self . maybe_init . seek_before_primary_effect ( Location {
85
84
block,
86
85
statement_index : data. statements . len ( ) ,
87
86
} ) ;
88
87
89
- // Check if the drop of `place` under inspection is really in effect.
90
- // This is true only when `place` may have been initialized along a control flow path from a BID to the drop program point today.
91
- // In other words, this is where the drop of `place` will happen in the future instead.
88
+ // Check if the drop of `place` under inspection is really in effect. This is
89
+ // true only when `place` may have been initialized along a control flow path
90
+ // from a BID to the drop program point today. In other words, this is where
91
+ // the drop of `place` will happen in the future instead.
92
92
if let MaybeReachable :: Reachable ( maybe_init) = self . maybe_init . get ( )
93
93
&& maybe_init. contains ( idx)
94
94
{
95
- // We also cache the drop information, so that we do not need to check on data-flow cursor again
95
+ // We also cache the drop information, so that we do not need to check on
96
+ // data-flow cursor again.
96
97
self . block_drop_value_info [ block] = MovePathIndexAtBlock :: Some ( idx) ;
97
98
dropped_local_here. borrow_mut ( ) . insert ( idx) ;
98
99
} else {
@@ -139,8 +140,9 @@ impl<'a, 'mir, 'tcx> DropsReachable<'a, 'mir, 'tcx> {
139
140
// Let's check the observed dropped places in.
140
141
self . collected_drops . union ( & * dropped_local_there. borrow ( ) ) ;
141
142
if self . drop_span . is_none ( ) {
142
- // FIXME(@dingxiangfei2009): it turns out that `self.body.source_scopes` are still a bit wonky.
143
- // There is a high chance that this span still points to a block rather than a statement semicolon.
143
+ // FIXME(@dingxiangfei2009): it turns out that `self.body.source_scopes` are
144
+ // still a bit wonky. There is a high chance that this span still points to a
145
+ // block rather than a statement semicolon.
144
146
* self . drop_span = Some ( terminator. source_info . span ) ;
145
147
}
146
148
// Now we have discovered a simple control flow path from a future drop point
@@ -394,10 +396,10 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<
394
396
for ( & block, candidates) in & bid_per_block {
395
397
// We will collect drops on locals on paths between BID points to their actual drop locations
396
398
// into `all_locals_dropped`.
397
- let mut all_locals_dropped = ChunkedBitSet :: new_empty ( move_data. move_paths . len ( ) ) ;
399
+ let mut all_locals_dropped = MixedBitSet :: new_empty ( move_data. move_paths . len ( ) ) ;
398
400
let mut drop_span = None ;
399
401
for & ( _, place) in candidates. iter ( ) {
400
- let mut collected_drops = ChunkedBitSet :: new_empty ( move_data. move_paths . len ( ) ) ;
402
+ let mut collected_drops = MixedBitSet :: new_empty ( move_data. move_paths . len ( ) ) ;
401
403
// ## On detecting change in relative drop order ##
402
404
// Iterate through each BID-containing block `block`.
403
405
// If the place `P` targeted by the BID is "maybe initialized",
@@ -425,8 +427,9 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<
425
427
426
428
// We shall now exclude some local bindings for the following cases.
427
429
{
428
- let mut to_exclude = ChunkedBitSet :: new_empty ( all_locals_dropped. domain_size ( ) ) ;
429
- // We will now do subtraction from the candidate dropped locals, because of the following reasons.
430
+ let mut to_exclude = MixedBitSet :: new_empty ( all_locals_dropped. domain_size ( ) ) ;
431
+ // We will now do subtraction from the candidate dropped locals, because of the
432
+ // following reasons.
430
433
for path_idx in all_locals_dropped. iter ( ) {
431
434
let move_path = & move_data. move_paths [ path_idx] ;
432
435
let dropped_local = move_path. place . local ;
0 commit comments