@@ -237,9 +237,6 @@ trait DropTreeBuilder<'tcx> {
237
237
238
238
impl DropTree {
239
239
fn new ( ) -> Self {
240
- // The root node of the tree doesn't represent a drop, but instead
241
- // represents the block in the tree that should be jumped to once all
242
- // of the required drops have been performed.
243
240
let fake_source_info = SourceInfo :: outermost ( DUMMY_SP ) ;
244
241
let fake_data =
245
242
DropData { source_info : fake_source_info, local : Local :: MAX , kind : DropKind :: Storage } ;
@@ -261,10 +258,6 @@ impl DropTree {
261
258
self . entry_points . push ( ( to, from) ) ;
262
259
}
263
260
264
- /// Builds the MIR for a given drop tree.
265
- ///
266
- /// `blocks` should have the same length as `self.drops`, and may have its
267
- /// first value set to some already existing block.
268
261
fn build_mir < ' tcx , T : DropTreeBuilder < ' tcx > > (
269
262
& mut self ,
270
263
cfg : & mut CFG < ' tcx > ,
@@ -1351,16 +1344,10 @@ impl<'tcx> DropTreeBuilder<'tcx> for GeneratorDrop {
1351
1344
cfg. start_new_block ( )
1352
1345
}
1353
1346
fn add_entry ( cfg : & mut CFG < ' tcx > , from : BasicBlock , to : BasicBlock ) {
1354
- let term = cfg. block_data_mut ( from) . terminator_mut ( ) ;
1355
- if let TerminatorKind :: Yield { ref mut drop, .. } = term . kind {
1347
+ let kind = & mut cfg. block_data_mut ( from) . terminator_mut ( ) . kind ;
1348
+ if let TerminatorKind :: Yield { drop, .. } = kind {
1356
1349
* drop = Some ( to) ;
1357
- } else {
1358
- span_bug ! (
1359
- term. source_info. span,
1360
- "cannot enter generator drop tree from {:?}" ,
1361
- term. kind
1362
- )
1363
- }
1350
+ } ;
1364
1351
}
1365
1352
}
1366
1353
@@ -1371,8 +1358,8 @@ impl<'tcx> DropTreeBuilder<'tcx> for Unwind {
1371
1358
cfg. start_new_cleanup_block ( )
1372
1359
}
1373
1360
fn add_entry ( cfg : & mut CFG < ' tcx > , from : BasicBlock , to : BasicBlock ) {
1374
- let term = & mut cfg. block_data_mut ( from) . terminator_mut ( ) ;
1375
- match & mut term. kind {
1361
+ let term = & mut cfg. block_data_mut ( from) . terminator_mut ( ) . kind ;
1362
+ match term {
1376
1363
TerminatorKind :: Drop { unwind, .. }
1377
1364
| TerminatorKind :: DropAndReplace { unwind, .. }
1378
1365
| TerminatorKind :: FalseUnwind { unwind, .. }
0 commit comments