@@ -620,48 +620,11 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
620620 self . elaborated_drop_block ( & inner_c)
621621 }
622622
623- fn open_drop_for_variant < ' a > ( & mut self ,
624- c : & DropCtxt < ' a , ' tcx > ,
625- drop_block : & mut Option < BasicBlock > ,
626- adt : & ' tcx ty:: AdtDef ,
627- substs : & ' tcx Substs < ' tcx > ,
628- variant_index : usize )
629- -> ( BasicBlock , bool )
630- {
631- let subpath = super :: move_path_children_matching (
632- self . move_data ( ) , c. path , |proj| match proj {
633- & Projection {
634- elem : ProjectionElem :: Downcast ( _, idx) , ..
635- } => idx == variant_index,
636- _ => false
637- } ) ;
638-
639- if let Some ( variant_path) = subpath {
640- let base_lv = c. lvalue . clone ( ) . elem (
641- ProjectionElem :: Downcast ( adt, variant_index)
642- ) ;
643- let fields = self . move_paths_for_fields (
644- & base_lv,
645- variant_path,
646- & adt. variants [ variant_index] ,
647- substs) ;
648- ( self . drop_ladder ( c, fields) , true )
649- } else {
650- // variant not found - drop the entire enum
651- if let None = * drop_block {
652- * drop_block = Some ( self . complete_drop ( c, true ) ) ;
653- }
654- ( drop_block. unwrap ( ) , false )
655- }
656- }
657-
658623 fn open_drop_for_adt < ' a > ( & mut self , c : & DropCtxt < ' a , ' tcx > ,
659624 adt : & ' tcx ty:: AdtDef , substs : & ' tcx Substs < ' tcx > )
660625 -> BasicBlock {
661626 debug ! ( "open_drop_for_adt({:?}, {:?}, {:?})" , c, adt, substs) ;
662627
663- let mut drop_block = None ;
664-
665628 match adt. variants . len ( ) {
666629 1 => {
667630 let fields = self . move_paths_for_fields (
@@ -676,17 +639,33 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
676639 let mut values = Vec :: with_capacity ( adt. variants . len ( ) ) ;
677640 let mut blocks = Vec :: with_capacity ( adt. variants . len ( ) ) ;
678641 let mut otherwise = None ;
679- for ( idx , variant) in adt. variants . iter ( ) . enumerate ( ) {
642+ for ( variant_index , variant) in adt. variants . iter ( ) . enumerate ( ) {
680643 let discr = ConstInt :: new_inttype ( variant. disr_val , adt. discr_ty ,
681644 self . tcx . sess . target . uint_type ,
682645 self . tcx . sess . target . int_type ) . unwrap ( ) ;
683- let ( blk, is_ladder) = self . open_drop_for_variant ( c, & mut drop_block, adt,
684- substs, idx) ;
685- if is_ladder {
646+ let subpath = super :: move_path_children_matching (
647+ self . move_data ( ) , c. path , |proj| match proj {
648+ & Projection {
649+ elem : ProjectionElem :: Downcast ( _, idx) , ..
650+ } => idx == variant_index,
651+ _ => false
652+ } ) ;
653+ if let Some ( variant_path) = subpath {
654+ let base_lv = c. lvalue . clone ( ) . elem (
655+ ProjectionElem :: Downcast ( adt, variant_index)
656+ ) ;
657+ let fields = self . move_paths_for_fields (
658+ & base_lv,
659+ variant_path,
660+ & adt. variants [ variant_index] ,
661+ substs) ;
686662 values. push ( discr) ;
687- blocks. push ( blk ) ;
663+ blocks. push ( self . drop_ladder ( c , fields ) ) ;
688664 } else {
689- otherwise = Some ( blk)
665+ // variant not found - drop the entire enum
666+ if let None = otherwise {
667+ otherwise = Some ( self . complete_drop ( c, true ) ) ;
668+ }
690669 }
691670 }
692671 if let Some ( block) = otherwise {
0 commit comments