@@ -548,17 +548,26 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
548
548
/// ELAB(drop location.2 [target=`c.unwind])
549
549
fn drop_ladder < ' a > ( & mut self ,
550
550
c : & DropCtxt < ' a , ' tcx > ,
551
- fields : & [ ( Lvalue < ' tcx > , Option < MovePathIndex > ) ] )
551
+ fields : Vec < ( Lvalue < ' tcx > , Option < MovePathIndex > ) > )
552
552
-> BasicBlock
553
553
{
554
554
debug ! ( "drop_ladder({:?}, {:?})" , c, fields) ;
555
+
556
+ let mut fields = fields;
557
+ fields. retain ( |& ( ref lvalue, _) | {
558
+ let ty = self . mir . lvalue_ty ( self . tcx , lvalue) . to_ty ( self . tcx ) ;
559
+ self . tcx . type_needs_drop_given_env ( ty, self . param_env ( ) )
560
+ } ) ;
561
+
562
+ debug ! ( "drop_ladder - fields needing drop: {:?}" , fields) ;
563
+
555
564
let unwind_ladder = if c. is_cleanup {
556
565
None
557
566
} else {
558
567
Some ( self . drop_halfladder ( c, None , c. unwind . unwrap ( ) , & fields, true ) )
559
568
} ;
560
569
561
- self . drop_halfladder ( c, unwind_ladder, c. succ , fields, c. is_cleanup )
570
+ self . drop_halfladder ( c, unwind_ladder, c. succ , & fields, c. is_cleanup )
562
571
. last ( ) . cloned ( ) . unwrap_or ( c. succ )
563
572
}
564
573
@@ -567,7 +576,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
567
576
{
568
577
debug ! ( "open_drop_for_tuple({:?}, {:?})" , c, tys) ;
569
578
570
- let fields: Vec < _ > = tys. iter ( ) . enumerate ( ) . map ( |( i, & ty) | {
579
+ let fields = tys. iter ( ) . enumerate ( ) . map ( |( i, & ty) | {
571
580
( c. lvalue . clone ( ) . field ( Field :: new ( i) , ty) ,
572
581
super :: move_path_children_matching (
573
582
& self . move_data ( ) . move_paths , c. path , |proj| match proj {
@@ -579,7 +588,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
579
588
) )
580
589
} ) . collect ( ) ;
581
590
582
- self . drop_ladder ( c, & fields)
591
+ self . drop_ladder ( c, fields)
583
592
}
584
593
585
594
fn open_drop_for_box < ' a > ( & mut self , c : & DropCtxt < ' a , ' tcx > , ty : Ty < ' tcx > )
@@ -634,7 +643,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
634
643
variant_path,
635
644
& adt. variants [ variant_index] ,
636
645
substs) ;
637
- self . drop_ladder ( c, & fields)
646
+ self . drop_ladder ( c, fields)
638
647
} else {
639
648
// variant not found - drop the entire enum
640
649
if let None = * drop_block {
@@ -659,7 +668,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
659
668
& adt. variants [ 0 ] ,
660
669
substs
661
670
) ;
662
- self . drop_ladder ( c, & fields)
671
+ self . drop_ladder ( c, fields)
663
672
}
664
673
_ => {
665
674
let variant_drops : Vec < BasicBlock > =
0 commit comments