@@ -211,7 +211,7 @@ use base::{custom_coerce_unsize_info, llvm_linkage_by_name};
211
211
use context:: CrateContext ;
212
212
use common:: { fulfill_obligation, normalize_and_test_predicates,
213
213
type_is_sized} ;
214
- use glue;
214
+ use glue:: { self , DropGlueKind } ;
215
215
use llvm;
216
216
use meth;
217
217
use monomorphize:: { self , Instance } ;
@@ -227,7 +227,7 @@ pub enum TransItemCollectionMode {
227
227
228
228
#[ derive( PartialEq , Eq , Clone , Copy , Debug ) ]
229
229
pub enum TransItem < ' tcx > {
230
- DropGlue ( Ty < ' tcx > ) ,
230
+ DropGlue ( DropGlueKind < ' tcx > ) ,
231
231
Fn ( Instance < ' tcx > ) ,
232
232
Static ( NodeId )
233
233
}
@@ -326,7 +326,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
326
326
let def_id = ccx. tcx ( ) . map . local_def_id ( node_id) ;
327
327
let ty = ccx. tcx ( ) . lookup_item_type ( def_id) . ty ;
328
328
let ty = glue:: get_drop_glue_type ( ccx, ty) ;
329
- neighbors. push ( TransItem :: DropGlue ( ty ) ) ;
329
+ neighbors. push ( TransItem :: DropGlue ( DropGlueKind :: Ty ( ty ) ) ) ;
330
330
recursion_depth_reset = None ;
331
331
}
332
332
TransItem :: Fn ( instance) => {
@@ -485,7 +485,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
485
485
& ty) ;
486
486
let ty = self . ccx . tcx ( ) . erase_regions ( & ty) ;
487
487
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 ) ) ) ;
489
489
}
490
490
491
491
self . super_lvalue ( lvalue, context) ;
@@ -575,9 +575,17 @@ fn can_have_local_instance<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
575
575
}
576
576
577
577
fn 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
+
581
589
debug ! ( "find_drop_glue_neighbors: {}" , type_to_string( ccx, ty) ) ;
582
590
583
591
// 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>,
634
642
& Substs :: empty ( ) ) ;
635
643
output. push ( trans_item) ;
636
644
}
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) ) ) ;
637
649
}
638
650
639
651
// Finally add the types of nested values
@@ -661,30 +673,30 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
661
673
let field_type = glue:: get_drop_glue_type ( ccx, field_type) ;
662
674
663
675
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) ) ) ;
665
677
}
666
678
}
667
679
}
668
680
ty:: TyClosure ( _, ref substs) => {
669
681
for upvar_ty in & substs. upvar_tys {
670
682
let upvar_ty = glue:: get_drop_glue_type ( ccx, upvar_ty) ;
671
683
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) ) ) ;
673
685
}
674
686
}
675
687
}
676
688
ty:: TyBox ( inner_type) |
677
689
ty:: TyArray ( inner_type, _) => {
678
690
let inner_type = glue:: get_drop_glue_type ( ccx, inner_type) ;
679
691
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) ) ) ;
681
693
}
682
694
}
683
695
ty:: TyTuple ( ref args) => {
684
696
for arg in args {
685
697
let arg = glue:: get_drop_glue_type ( ccx, arg) ;
686
698
if glue:: type_needs_drop ( ccx. tcx ( ) , arg) {
687
- output. push ( TransItem :: DropGlue ( arg) ) ;
699
+ output. push ( TransItem :: DropGlue ( DropGlueKind :: Ty ( arg) ) ) ;
688
700
}
689
701
}
690
702
}
@@ -1000,7 +1012,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1000
1012
self . ccx. tcx( ) . map. local_def_id( item. id) ) ) ;
1001
1013
1002
1014
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 ) ) ) ;
1004
1016
}
1005
1017
}
1006
1018
}
@@ -1413,10 +1425,13 @@ impl<'tcx> TransItem<'tcx> {
1413
1425
let hir_map = & ccx. tcx ( ) . map ;
1414
1426
1415
1427
return match * self {
1416
- TransItem :: DropGlue ( t ) => {
1428
+ TransItem :: DropGlue ( dg ) => {
1417
1429
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) ;
1420
1435
s
1421
1436
}
1422
1437
TransItem :: Fn ( instance) => {
@@ -1442,8 +1457,8 @@ impl<'tcx> TransItem<'tcx> {
1442
1457
1443
1458
fn to_raw_string ( & self ) -> String {
1444
1459
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 )
1447
1462
}
1448
1463
TransItem :: Fn ( instance) => {
1449
1464
format ! ( "Fn({:?}, {})" ,
0 commit comments