@@ -548,17 +548,26 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
548548 /// ELAB(drop location.2 [target=`c.unwind])
549549 fn drop_ladder < ' a > ( & mut self ,
550550 c : & DropCtxt < ' a , ' tcx > ,
551- fields : & [ ( Lvalue < ' tcx > , Option < MovePathIndex > ) ] )
551+ fields : Vec < ( Lvalue < ' tcx > , Option < MovePathIndex > ) > )
552552 -> BasicBlock
553553 {
554554 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+
555564 let unwind_ladder = if c. is_cleanup {
556565 None
557566 } else {
558567 Some ( self . drop_halfladder ( c, None , c. unwind . unwrap ( ) , & fields, true ) )
559568 } ;
560569
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 )
562571 . last ( ) . cloned ( ) . unwrap_or ( c. succ )
563572 }
564573
@@ -567,7 +576,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
567576 {
568577 debug ! ( "open_drop_for_tuple({:?}, {:?})" , c, tys) ;
569578
570- let fields: Vec < _ > = tys. iter ( ) . enumerate ( ) . map ( |( i, & ty) | {
579+ let fields = tys. iter ( ) . enumerate ( ) . map ( |( i, & ty) | {
571580 ( c. lvalue . clone ( ) . field ( Field :: new ( i) , ty) ,
572581 super :: move_path_children_matching (
573582 & self . move_data ( ) . move_paths , c. path , |proj| match proj {
@@ -579,7 +588,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
579588 ) )
580589 } ) . collect ( ) ;
581590
582- self . drop_ladder ( c, & fields)
591+ self . drop_ladder ( c, fields)
583592 }
584593
585594 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> {
634643 variant_path,
635644 & adt. variants [ variant_index] ,
636645 substs) ;
637- self . drop_ladder ( c, & fields)
646+ self . drop_ladder ( c, fields)
638647 } else {
639648 // variant not found - drop the entire enum
640649 if let None = * drop_block {
@@ -659,7 +668,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
659668 & adt. variants [ 0 ] ,
660669 substs
661670 ) ;
662- self . drop_ladder ( c, & fields)
671+ self . drop_ladder ( c, fields)
663672 }
664673 _ => {
665674 let variant_drops : Vec < BasicBlock > =
0 commit comments