@@ -209,7 +209,7 @@ const ROOT_NODE: DropIdx = DropIdx::ZERO;
209
209
#[ derive( Debug ) ]
210
210
struct DropTree {
211
211
/// Nodes in the drop tree, containing drop data and a link to the next node.
212
- drops : IndexVec < DropIdx , DropNode > ,
212
+ drop_nodes : IndexVec < DropIdx , DropNode > ,
213
213
/// Map for finding the index of an existing node, given its contents.
214
214
existing_drops_map : FxHashMap < DropNodeKey , DropIdx > ,
215
215
/// Edges into the `DropTree` that need to be added once it's lowered.
@@ -277,8 +277,8 @@ impl DropTree {
277
277
let fake_source_info = SourceInfo :: outermost ( DUMMY_SP ) ;
278
278
let fake_data =
279
279
DropData { source_info : fake_source_info, local : Local :: MAX , kind : DropKind :: Storage } ;
280
- let drops = IndexVec :: from_raw ( vec ! [ DropNode { data: fake_data, next: DropIdx :: MAX } ] ) ;
281
- Self { drops , entry_points : Vec :: new ( ) , existing_drops_map : FxHashMap :: default ( ) }
280
+ let drop_nodes = IndexVec :: from_raw ( vec ! [ DropNode { data: fake_data, next: DropIdx :: MAX } ] ) ;
281
+ Self { drop_nodes , entry_points : Vec :: new ( ) , existing_drops_map : FxHashMap :: default ( ) }
282
282
}
283
283
284
284
/// Adds a node to the drop tree, consisting of drop data and the index of
@@ -287,20 +287,20 @@ impl DropTree {
287
287
/// If there is already an equivalent node in the tree, nothing is added, and
288
288
/// that node's index is returned. Otherwise, the new node's index is returned.
289
289
fn add_drop ( & mut self , data : DropData , next : DropIdx ) -> DropIdx {
290
- let drops = & mut self . drops ;
290
+ let drop_nodes = & mut self . drop_nodes ;
291
291
* self
292
292
. existing_drops_map
293
293
. entry ( DropNodeKey { next, local : data. local } )
294
294
// Create a new node, and also add its index to the map.
295
- . or_insert_with ( || drops . push ( DropNode { data, next } ) )
295
+ . or_insert_with ( || drop_nodes . push ( DropNode { data, next } ) )
296
296
}
297
297
298
298
/// Registers `from` as an entry point to this drop tree, at `to`.
299
299
///
300
300
/// During [`Self::build_mir`], `from` will be linked to the corresponding
301
301
/// block within the drop tree.
302
302
fn add_entry_point ( & mut self , from : BasicBlock , to : DropIdx ) {
303
- debug_assert ! ( to < self . drops . next_index( ) ) ;
303
+ debug_assert ! ( to < self . drop_nodes . next_index( ) ) ;
304
304
self . entry_points . push ( ( to, from) ) ;
305
305
}
306
306
@@ -340,10 +340,10 @@ impl DropTree {
340
340
Own ,
341
341
}
342
342
343
- let mut blocks = IndexVec :: from_elem ( None , & self . drops ) ;
343
+ let mut blocks = IndexVec :: from_elem ( None , & self . drop_nodes ) ;
344
344
blocks[ ROOT_NODE ] = root_node;
345
345
346
- let mut needs_block = IndexVec :: from_elem ( Block :: None , & self . drops ) ;
346
+ let mut needs_block = IndexVec :: from_elem ( Block :: None , & self . drop_nodes ) ;
347
347
if root_node. is_some ( ) {
348
348
// In some cases (such as drops for `continue`) the root node
349
349
// already has a block. In this case, make sure that we don't
@@ -355,7 +355,7 @@ impl DropTree {
355
355
let entry_points = & mut self . entry_points ;
356
356
entry_points. sort ( ) ;
357
357
358
- for ( drop_idx, drop_node) in self . drops . iter_enumerated ( ) . rev ( ) {
358
+ for ( drop_idx, drop_node) in self . drop_nodes . iter_enumerated ( ) . rev ( ) {
359
359
if entry_points. last ( ) . is_some_and ( |entry_point| entry_point. 0 == drop_idx) {
360
360
let block = * blocks[ drop_idx] . get_or_insert_with ( || T :: make_block ( cfg) ) ;
361
361
needs_block[ drop_idx] = Block :: Own ;
@@ -395,7 +395,7 @@ impl DropTree {
395
395
cfg : & mut CFG < ' tcx > ,
396
396
blocks : & IndexSlice < DropIdx , Option < BasicBlock > > ,
397
397
) {
398
- for ( drop_idx, drop_node) in self . drops . iter_enumerated ( ) . rev ( ) {
398
+ for ( drop_idx, drop_node) in self . drop_nodes . iter_enumerated ( ) . rev ( ) {
399
399
let Some ( block) = blocks[ drop_idx] else { continue } ;
400
400
match drop_node. data . kind {
401
401
DropKind :: Value => {
@@ -828,9 +828,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
828
828
// `unwind_to` should drop the value that we're about to
829
829
// schedule. If dropping this value panics, then we continue
830
830
// with the *next* value on the unwind path.
831
- debug_assert_eq ! ( unwind_drops. drops[ unwind_to] . data. local, drop_data. local) ;
832
- debug_assert_eq ! ( unwind_drops. drops[ unwind_to] . data. kind, drop_data. kind) ;
833
- unwind_to = unwind_drops. drops [ unwind_to] . next ;
831
+ debug_assert_eq ! (
832
+ unwind_drops. drop_nodes[ unwind_to] . data. local,
833
+ drop_data. local
834
+ ) ;
835
+ debug_assert_eq ! (
836
+ unwind_drops. drop_nodes[ unwind_to] . data. kind,
837
+ drop_data. kind
838
+ ) ;
839
+ unwind_to = unwind_drops. drop_nodes [ unwind_to] . next ;
834
840
835
841
let mut unwind_entry_point = unwind_to;
836
842
@@ -1550,14 +1556,14 @@ where
1550
1556
//
1551
1557
// We adjust this BEFORE we create the drop (e.g., `drops[n]`)
1552
1558
// because `drops[n]` should unwind to `drops[n-1]`.
1553
- debug_assert_eq ! ( unwind_drops. drops [ unwind_to] . data. local, drop_data. local) ;
1554
- debug_assert_eq ! ( unwind_drops. drops [ unwind_to] . data. kind, drop_data. kind) ;
1555
- unwind_to = unwind_drops. drops [ unwind_to] . next ;
1559
+ debug_assert_eq ! ( unwind_drops. drop_nodes [ unwind_to] . data. local, drop_data. local) ;
1560
+ debug_assert_eq ! ( unwind_drops. drop_nodes [ unwind_to] . data. kind, drop_data. kind) ;
1561
+ unwind_to = unwind_drops. drop_nodes [ unwind_to] . next ;
1556
1562
1557
1563
if let Some ( idx) = dropline_to {
1558
- debug_assert_eq ! ( coroutine_drops. drops [ idx] . data. local, drop_data. local) ;
1559
- debug_assert_eq ! ( coroutine_drops. drops [ idx] . data. kind, drop_data. kind) ;
1560
- dropline_to = Some ( coroutine_drops. drops [ idx] . next ) ;
1564
+ debug_assert_eq ! ( coroutine_drops. drop_nodes [ idx] . data. local, drop_data. local) ;
1565
+ debug_assert_eq ! ( coroutine_drops. drop_nodes [ idx] . data. kind, drop_data. kind) ;
1566
+ dropline_to = Some ( coroutine_drops. drop_nodes [ idx] . next ) ;
1561
1567
}
1562
1568
1563
1569
// If the operand has been moved, and we are not on an unwind
@@ -1597,9 +1603,12 @@ where
1597
1603
// cases we emit things ALSO on the unwind path, so we need to adjust
1598
1604
// `unwind_to` in that case.
1599
1605
if storage_dead_on_unwind {
1600
- debug_assert_eq ! ( unwind_drops. drops[ unwind_to] . data. local, drop_data. local) ;
1601
- debug_assert_eq ! ( unwind_drops. drops[ unwind_to] . data. kind, drop_data. kind) ;
1602
- unwind_to = unwind_drops. drops [ unwind_to] . next ;
1606
+ debug_assert_eq ! (
1607
+ unwind_drops. drop_nodes[ unwind_to] . data. local,
1608
+ drop_data. local
1609
+ ) ;
1610
+ debug_assert_eq ! ( unwind_drops. drop_nodes[ unwind_to] . data. kind, drop_data. kind) ;
1611
+ unwind_to = unwind_drops. drop_nodes [ unwind_to] . next ;
1603
1612
}
1604
1613
1605
1614
// If the operand has been moved, and we are not on an unwind
@@ -1628,14 +1637,17 @@ where
1628
1637
// the storage-dead has completed, we need to adjust the `unwind_to` pointer
1629
1638
// so that any future drops we emit will not register storage-dead.
1630
1639
if storage_dead_on_unwind {
1631
- debug_assert_eq ! ( unwind_drops. drops[ unwind_to] . data. local, drop_data. local) ;
1632
- debug_assert_eq ! ( unwind_drops. drops[ unwind_to] . data. kind, drop_data. kind) ;
1633
- unwind_to = unwind_drops. drops [ unwind_to] . next ;
1640
+ debug_assert_eq ! (
1641
+ unwind_drops. drop_nodes[ unwind_to] . data. local,
1642
+ drop_data. local
1643
+ ) ;
1644
+ debug_assert_eq ! ( unwind_drops. drop_nodes[ unwind_to] . data. kind, drop_data. kind) ;
1645
+ unwind_to = unwind_drops. drop_nodes [ unwind_to] . next ;
1634
1646
}
1635
1647
if let Some ( idx) = dropline_to {
1636
- debug_assert_eq ! ( coroutine_drops. drops [ idx] . data. local, drop_data. local) ;
1637
- debug_assert_eq ! ( coroutine_drops. drops [ idx] . data. kind, drop_data. kind) ;
1638
- dropline_to = Some ( coroutine_drops. drops [ idx] . next ) ;
1648
+ debug_assert_eq ! ( coroutine_drops. drop_nodes [ idx] . data. local, drop_data. local) ;
1649
+ debug_assert_eq ! ( coroutine_drops. drop_nodes [ idx] . data. kind, drop_data. kind) ;
1650
+ dropline_to = Some ( coroutine_drops. drop_nodes [ idx] . next ) ;
1639
1651
}
1640
1652
// Only temps and vars need their storage dead.
1641
1653
assert ! ( local. index( ) > arg_count) ;
@@ -1662,10 +1674,10 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> {
1662
1674
let is_coroutine = self . coroutine . is_some ( ) ;
1663
1675
1664
1676
// Link the exit drop tree to unwind drop tree.
1665
- if drops. drops . iter ( ) . any ( |drop_node| drop_node. data . kind == DropKind :: Value ) {
1677
+ if drops. drop_nodes . iter ( ) . any ( |drop_node| drop_node. data . kind == DropKind :: Value ) {
1666
1678
let unwind_target = self . diverge_cleanup_target ( else_scope, span) ;
1667
1679
let mut unwind_indices = IndexVec :: from_elem_n ( unwind_target, 1 ) ;
1668
- for ( drop_idx, drop_node) in drops. drops . iter_enumerated ( ) . skip ( 1 ) {
1680
+ for ( drop_idx, drop_node) in drops. drop_nodes . iter_enumerated ( ) . skip ( 1 ) {
1669
1681
match drop_node. data . kind {
1670
1682
DropKind :: Storage | DropKind :: ForLint => {
1671
1683
if is_coroutine {
@@ -1694,13 +1706,13 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> {
1694
1706
}
1695
1707
// Link the exit drop tree to dropline drop tree (coroutine drop path) for async drops
1696
1708
if is_coroutine
1697
- && drops. drops . iter ( ) . any ( |DropNode { data, next : _ } | {
1709
+ && drops. drop_nodes . iter ( ) . any ( |DropNode { data, next : _ } | {
1698
1710
data. kind == DropKind :: Value && self . is_async_drop ( data. local )
1699
1711
} )
1700
1712
{
1701
1713
let dropline_target = self . diverge_dropline_target ( else_scope, span) ;
1702
1714
let mut dropline_indices = IndexVec :: from_elem_n ( dropline_target, 1 ) ;
1703
- for ( drop_idx, drop_data) in drops. drops . iter_enumerated ( ) . skip ( 1 ) {
1715
+ for ( drop_idx, drop_data) in drops. drop_nodes . iter_enumerated ( ) . skip ( 1 ) {
1704
1716
match drop_data. data . kind {
1705
1717
DropKind :: Storage | DropKind :: ForLint => {
1706
1718
let coroutine_drop = self
@@ -1768,11 +1780,11 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> {
1768
1780
// prevent drop elaboration from creating drop flags that would have
1769
1781
// to be captured by the coroutine. I'm not sure how important this
1770
1782
// optimization is, but it is here.
1771
- for ( drop_idx, drop_node) in drops. drops . iter_enumerated ( ) {
1783
+ for ( drop_idx, drop_node) in drops. drop_nodes . iter_enumerated ( ) {
1772
1784
if let DropKind :: Value = drop_node. data . kind
1773
1785
&& let Some ( bb) = blocks[ drop_idx]
1774
1786
{
1775
- debug_assert ! ( drop_node. next < drops. drops . next_index( ) ) ;
1787
+ debug_assert ! ( drop_node. next < drops. drop_nodes . next_index( ) ) ;
1776
1788
drops. entry_points . push ( ( drop_node. next , bb) ) ;
1777
1789
}
1778
1790
}
0 commit comments