@@ -211,7 +211,7 @@ use base::{custom_coerce_unsize_info, llvm_linkage_by_name};
211211use context:: CrateContext ;
212212use common:: { fulfill_obligation, normalize_and_test_predicates,
213213 type_is_sized} ;
214- use glue;
214+ use glue:: { self , DropGlueKind } ;
215215use llvm;
216216use meth;
217217use monomorphize:: { self , Instance } ;
@@ -227,7 +227,7 @@ pub enum TransItemCollectionMode {
227227
228228#[ derive( PartialEq , Eq , Clone , Copy , Debug ) ]
229229pub enum TransItem < ' tcx > {
230- DropGlue ( Ty < ' tcx > ) ,
230+ DropGlue ( DropGlueKind < ' tcx > ) ,
231231 Fn ( Instance < ' tcx > ) ,
232232 Static ( NodeId )
233233}
@@ -326,7 +326,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
326326 let def_id = ccx. tcx ( ) . map . local_def_id ( node_id) ;
327327 let ty = ccx. tcx ( ) . lookup_item_type ( def_id) . ty ;
328328 let ty = glue:: get_drop_glue_type ( ccx, ty) ;
329- neighbors. push ( TransItem :: DropGlue ( ty ) ) ;
329+ neighbors. push ( TransItem :: DropGlue ( DropGlueKind :: Ty ( ty ) ) ) ;
330330 recursion_depth_reset = None ;
331331 }
332332 TransItem :: Fn ( instance) => {
@@ -485,7 +485,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
485485 & ty) ;
486486 let ty = self . ccx . tcx ( ) . erase_regions ( & ty) ;
487487 let ty = glue:: get_drop_glue_type ( self . ccx , ty) ;
488- self . output . push ( TransItem :: DropGlue ( ty ) ) ;
488+ self . output . push ( TransItem :: DropGlue ( DropGlueKind :: Ty ( ty ) ) ) ;
489489 }
490490
491491 self . super_lvalue ( lvalue, context) ;
@@ -575,9 +575,17 @@ fn can_have_local_instance<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
575575}
576576
577577fn find_drop_glue_neighbors < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
578- ty : ty:: Ty < ' tcx > ,
579- output : & mut Vec < TransItem < ' tcx > > )
580- {
578+ dg : DropGlueKind < ' tcx > ,
579+ output : & mut Vec < TransItem < ' tcx > > ) {
580+ let ty = match dg {
581+ DropGlueKind :: Ty ( ty) => ty,
582+ DropGlueKind :: TyContents ( _) => {
583+ // We already collected the neighbors of this item via the
584+ // DropGlueKind::Ty variant.
585+ return
586+ }
587+ } ;
588+
581589 debug ! ( "find_drop_glue_neighbors: {}" , type_to_string( ccx, ty) ) ;
582590
583591 // Make sure the exchange_free_fn() lang-item gets translated if
@@ -634,6 +642,10 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
634642 & Substs :: empty ( ) ) ;
635643 output. push ( trans_item) ;
636644 }
645+
646+ // This type has a Drop implementation, we'll need the contents-only
647+ // version of the glue too.
648+ output. push ( TransItem :: DropGlue ( DropGlueKind :: TyContents ( ty) ) ) ;
637649 }
638650
639651 // Finally add the types of nested values
@@ -661,30 +673,30 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
661673 let field_type = glue:: get_drop_glue_type ( ccx, field_type) ;
662674
663675 if glue:: type_needs_drop ( ccx. tcx ( ) , field_type) {
664- output. push ( TransItem :: DropGlue ( field_type) ) ;
676+ output. push ( TransItem :: DropGlue ( DropGlueKind :: Ty ( field_type) ) ) ;
665677 }
666678 }
667679 }
668680 ty:: TyClosure ( _, ref substs) => {
669681 for upvar_ty in & substs. upvar_tys {
670682 let upvar_ty = glue:: get_drop_glue_type ( ccx, upvar_ty) ;
671683 if glue:: type_needs_drop ( ccx. tcx ( ) , upvar_ty) {
672- output. push ( TransItem :: DropGlue ( upvar_ty) ) ;
684+ output. push ( TransItem :: DropGlue ( DropGlueKind :: Ty ( upvar_ty) ) ) ;
673685 }
674686 }
675687 }
676688 ty:: TyBox ( inner_type) |
677689 ty:: TyArray ( inner_type, _) => {
678690 let inner_type = glue:: get_drop_glue_type ( ccx, inner_type) ;
679691 if glue:: type_needs_drop ( ccx. tcx ( ) , inner_type) {
680- output. push ( TransItem :: DropGlue ( inner_type) ) ;
692+ output. push ( TransItem :: DropGlue ( DropGlueKind :: Ty ( inner_type) ) ) ;
681693 }
682694 }
683695 ty:: TyTuple ( ref args) => {
684696 for arg in args {
685697 let arg = glue:: get_drop_glue_type ( ccx, arg) ;
686698 if glue:: type_needs_drop ( ccx. tcx ( ) , arg) {
687- output. push ( TransItem :: DropGlue ( arg) ) ;
699+ output. push ( TransItem :: DropGlue ( DropGlueKind :: Ty ( arg) ) ) ;
688700 }
689701 }
690702 }
@@ -1000,7 +1012,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
10001012 self . ccx. tcx( ) . map. local_def_id( item. id) ) ) ;
10011013
10021014 let ty = glue:: get_drop_glue_type ( self . ccx , ty) ;
1003- self . output . push ( TransItem :: DropGlue ( ty ) ) ;
1015+ self . output . push ( TransItem :: DropGlue ( DropGlueKind :: Ty ( ty ) ) ) ;
10041016 }
10051017 }
10061018 }
@@ -1413,10 +1425,13 @@ impl<'tcx> TransItem<'tcx> {
14131425 let hir_map = & ccx. tcx ( ) . map ;
14141426
14151427 return match * self {
1416- TransItem :: DropGlue ( t ) => {
1428+ TransItem :: DropGlue ( dg ) => {
14171429 let mut s = String :: with_capacity ( 32 ) ;
1418- s. push_str ( "drop-glue " ) ;
1419- push_unique_type_name ( ccx, t, & mut s) ;
1430+ match dg {
1431+ DropGlueKind :: Ty ( _) => s. push_str ( "drop-glue " ) ,
1432+ DropGlueKind :: TyContents ( _) => s. push_str ( "drop-glue-contents " ) ,
1433+ } ;
1434+ push_unique_type_name ( ccx, dg. ty ( ) , & mut s) ;
14201435 s
14211436 }
14221437 TransItem :: Fn ( instance) => {
@@ -1442,8 +1457,8 @@ impl<'tcx> TransItem<'tcx> {
14421457
14431458 fn to_raw_string ( & self ) -> String {
14441459 match * self {
1445- TransItem :: DropGlue ( t ) => {
1446- format ! ( "DropGlue({})" , t as * const _ as usize )
1460+ TransItem :: DropGlue ( dg ) => {
1461+ format ! ( "DropGlue({})" , dg . ty ( ) as * const _ as usize )
14471462 }
14481463 TransItem :: Fn ( instance) => {
14491464 format ! ( "Fn({:?}, {})" ,
0 commit comments