@@ -209,7 +209,7 @@ const ROOT_NODE: DropIdx = DropIdx::ZERO;
209209#[ derive( Debug ) ]
210210struct DropTree {
211211/// 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 > ,
213213/// Map for finding the index of an existing node, given its contents.
214214existing_drops_map : FxHashMap < DropNodeKey , DropIdx > ,
215215/// Edges into the `DropTree` that need to be added once it's lowered.
@@ -277,8 +277,8 @@ impl DropTree {
277277let fake_source_info = SourceInfo :: outermost ( DUMMY_SP ) ;
278278let fake_data =
279279DropData { 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 ( ) }
282282}
283283
284284/// Adds a node to the drop tree, consisting of drop data and the index of
@@ -287,20 +287,20 @@ impl DropTree {
287287/// If there is already an equivalent node in the tree, nothing is added, and
288288/// that node's index is returned. Otherwise, the new node's index is returned.
289289fn add_drop ( & mut self , data : DropData , next : DropIdx ) -> DropIdx {
290- let drops = & mut self . drops ;
290+ let drop_nodes = & mut self . drop_nodes ;
291291* self
292292. existing_drops_map
293293. entry ( DropNodeKey { next, local : data. local } )
294294// 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 } ) )
296296}
297297
298298/// Registers `from` as an entry point to this drop tree, at `to`.
299299///
300300/// During [`Self::build_mir`], `from` will be linked to the corresponding
301301/// block within the drop tree.
302302fn 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( ) ) ;
304304self . entry_points . push ( ( to, from) ) ;
305305}
306306
@@ -340,10 +340,10 @@ impl DropTree {
340340Own ,
341341}
342342
343- let mut blocks = IndexVec :: from_elem ( None , & self . drops ) ;
343+ let mut blocks = IndexVec :: from_elem ( None , & self . drop_nodes ) ;
344344 blocks[ ROOT_NODE ] = root_node;
345345
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 ) ;
347347if root_node. is_some ( ) {
348348// In some cases (such as drops for `continue`) the root node
349349// already has a block. In this case, make sure that we don't
@@ -355,7 +355,7 @@ impl DropTree {
355355let entry_points = & mut self . entry_points ;
356356 entry_points. sort ( ) ;
357357
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 ( ) {
359359if entry_points. last ( ) . is_some_and ( |entry_point| entry_point. 0 == drop_idx) {
360360let block = * blocks[ drop_idx] . get_or_insert_with ( || T :: make_block ( cfg) ) ;
361361 needs_block[ drop_idx] = Block :: Own ;
@@ -395,7 +395,7 @@ impl DropTree {
395395cfg : & mut CFG < ' tcx > ,
396396blocks : & IndexSlice < DropIdx , Option < BasicBlock > > ,
397397) {
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 ( ) {
399399let Some ( block) = blocks[ drop_idx] else { continue } ;
400400match drop_node. data . kind {
401401DropKind :: Value => {
@@ -828,9 +828,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
828828// `unwind_to` should drop the value that we're about to
829829// schedule. If dropping this value panics, then we continue
830830// 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 ;
834840
835841let mut unwind_entry_point = unwind_to;
836842
@@ -1550,14 +1556,14 @@ where
15501556//
15511557// We adjust this BEFORE we create the drop (e.g., `drops[n]`)
15521558// 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 ;
15561562
15571563if 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 ) ;
15611567}
15621568
15631569// If the operand has been moved, and we are not on an unwind
@@ -1597,9 +1603,12 @@ where
15971603// cases we emit things ALSO on the unwind path, so we need to adjust
15981604// `unwind_to` in that case.
15991605if 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 ;
16031612}
16041613
16051614// If the operand has been moved, and we are not on an unwind
@@ -1628,14 +1637,17 @@ where
16281637// the storage-dead has completed, we need to adjust the `unwind_to` pointer
16291638// so that any future drops we emit will not register storage-dead.
16301639if 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 ;
16341646}
16351647if 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 ) ;
16391651}
16401652// Only temps and vars need their storage dead.
16411653assert ! ( local. index( ) > arg_count) ;
@@ -1662,10 +1674,10 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> {
16621674let is_coroutine = self . coroutine . is_some ( ) ;
16631675
16641676// 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 ) {
16661678let unwind_target = self . diverge_cleanup_target ( else_scope, span) ;
16671679let 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 ) {
16691681match drop_node. data . kind {
16701682DropKind :: Storage | DropKind :: ForLint => {
16711683if is_coroutine {
@@ -1694,13 +1706,13 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> {
16941706}
16951707// Link the exit drop tree to dropline drop tree (coroutine drop path) for async drops
16961708if is_coroutine
1697- && drops. drops . iter ( ) . any ( |DropNode { data, next : _ } | {
1709+ && drops. drop_nodes . iter ( ) . any ( |DropNode { data, next : _ } | {
16981710 data. kind == DropKind :: Value && self . is_async_drop ( data. local )
16991711} )
17001712{
17011713let dropline_target = self . diverge_dropline_target ( else_scope, span) ;
17021714let 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 ) {
17041716match drop_data. data . kind {
17051717DropKind :: Storage | DropKind :: ForLint => {
17061718let coroutine_drop = self
@@ -1768,11 +1780,11 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> {
17681780// prevent drop elaboration from creating drop flags that would have
17691781// to be captured by the coroutine. I'm not sure how important this
17701782// 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 ( ) {
17721784if let DropKind :: Value = drop_node. data . kind
17731785 && let Some ( bb) = blocks[ drop_idx]
17741786{
1775- debug_assert ! ( drop_node. next < drops. drops . next_index( ) ) ;
1787+ debug_assert ! ( drop_node. next < drops. drop_nodes . next_index( ) ) ;
17761788 drops. entry_points . push ( ( drop_node. next , bb) ) ;
17771789}
17781790}
0 commit comments