@@ -7,7 +7,7 @@ use rustc_data_structures::unord::{UnordMap, UnordSet};
77use rustc_errors:: Subdiagnostic ;
88use rustc_hir:: CRATE_HIR_ID ;
99use rustc_hir:: def_id:: { DefId , LocalDefId } ;
10- use rustc_index:: bit_set:: ChunkedBitSet ;
10+ use rustc_index:: bit_set:: MixedBitSet ;
1111use rustc_index:: { IndexSlice , IndexVec } ;
1212use rustc_macros:: { LintDiagnostic , Subdiagnostic } ;
1313use rustc_middle:: bug;
@@ -49,24 +49,24 @@ struct DropsReachable<'a, 'mir, 'tcx> {
4949 move_data : & ' a MoveData < ' tcx > ,
5050 maybe_init : & ' a mut ResultsCursor < ' mir , ' tcx , MaybeInitializedPlaces < ' mir , ' tcx > > ,
5151 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 > > > > ,
5454}
5555
5656impl < ' a , ' mir , ' tcx > DropsReachable < ' a , ' mir , ' tcx > {
5757 fn visit ( & mut self , block : BasicBlock ) {
5858 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) ) ) ;
6060
6161 let data = & self . body . basic_blocks [ block] ;
6262 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.
6666 let dropped_local_here =
6767 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`.
7070 match self . block_drop_value_info [ block] {
7171 MovePathIndexAtBlock :: Some ( dropped) => {
7272 dropped_local_here. borrow_mut ( ) . insert ( dropped) ;
@@ -76,23 +76,24 @@ impl<'a, 'mir, 'tcx> DropsReachable<'a, 'mir, 'tcx> {
7676 && let LookupResult :: Exact ( idx) | LookupResult :: Parent ( Some ( idx) ) =
7777 self . move_data . rev_lookup . find ( place. as_ref ( ) )
7878 {
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.
8483 self . maybe_init . seek_before_primary_effect ( Location {
8584 block,
8685 statement_index : data. statements . len ( ) ,
8786 } ) ;
8887
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.
9292 if let MaybeReachable :: Reachable ( maybe_init) = self . maybe_init . get ( )
9393 && maybe_init. contains ( idx)
9494 {
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.
9697 self . block_drop_value_info [ block] = MovePathIndexAtBlock :: Some ( idx) ;
9798 dropped_local_here. borrow_mut ( ) . insert ( idx) ;
9899 } else {
@@ -139,8 +140,9 @@ impl<'a, 'mir, 'tcx> DropsReachable<'a, 'mir, 'tcx> {
139140 // Let's check the observed dropped places in.
140141 self . collected_drops . union ( & * dropped_local_there. borrow ( ) ) ;
141142 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.
144146 * self . drop_span = Some ( terminator. source_info . span ) ;
145147 }
146148 // 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<
394396 for ( & block, candidates) in & bid_per_block {
395397 // We will collect drops on locals on paths between BID points to their actual drop locations
396398 // 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 ( ) ) ;
398400 let mut drop_span = None ;
399401 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 ( ) ) ;
401403 // ## On detecting change in relative drop order ##
402404 // Iterate through each BID-containing block `block`.
403405 // 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<
425427
426428 // We shall now exclude some local bindings for the following cases.
427429 {
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.
430433 for path_idx in all_locals_dropped. iter ( ) {
431434 let move_path = & move_data. move_paths [ path_idx] ;
432435 let dropped_local = move_path. place . local ;
0 commit comments