@@ -202,9 +202,9 @@ use rustc::mir::repr as mir;
202
202
use rustc:: mir:: visit as mir_visit;
203
203
use rustc:: mir:: visit:: Visitor as MirVisitor ;
204
204
205
+ use syntax:: abi:: Abi ;
205
206
use syntax:: codemap:: DUMMY_SP ;
206
207
use syntax:: errors;
207
-
208
208
use base:: custom_coerce_unsize_info;
209
209
use context:: SharedCrateContext ;
210
210
use common:: { fulfill_obligation, normalize_and_test_predicates, type_is_sized} ;
@@ -602,6 +602,49 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
602
602
can_have_local_instance ( tcx, def_id)
603
603
}
604
604
}
605
+
606
+ // This takes care of the "drop_in_place" intrinsic for which we otherwise
607
+ // we would not register drop-glues.
608
+ fn visit_terminator_kind ( & mut self ,
609
+ block : mir:: BasicBlock ,
610
+ kind : & mir:: TerminatorKind < ' tcx > ) {
611
+ let tcx = self . scx . tcx ( ) ;
612
+ match * kind {
613
+ mir:: TerminatorKind :: Call {
614
+ func : mir:: Operand :: Constant ( ref constant) ,
615
+ ref args,
616
+ ..
617
+ } => {
618
+ match constant. ty . sty {
619
+ ty:: TyFnDef ( def_id, _, bare_fn_ty)
620
+ if is_drop_in_place_intrinsic ( tcx, def_id, bare_fn_ty) => {
621
+ let operand_ty = self . mir . operand_ty ( tcx, & args[ 0 ] ) ;
622
+ if let ty:: TyRawPtr ( mt) = operand_ty. sty {
623
+ let operand_ty = monomorphize:: apply_param_substs ( tcx,
624
+ self . param_substs ,
625
+ & mt. ty ) ;
626
+ self . output . push ( TransItem :: DropGlue ( DropGlueKind :: Ty ( operand_ty) ) ) ;
627
+ } else {
628
+ bug ! ( "Has the drop_in_place() intrinsic's signature changed?" )
629
+ }
630
+ }
631
+ _ => { /* Nothing to do. */ }
632
+ }
633
+ }
634
+ _ => { /* Nothing to do. */ }
635
+ }
636
+
637
+ self . super_terminator_kind ( block, kind) ;
638
+
639
+ fn is_drop_in_place_intrinsic < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
640
+ def_id : DefId ,
641
+ bare_fn_ty : & ty:: BareFnTy < ' tcx > )
642
+ -> bool {
643
+ ( bare_fn_ty. abi == Abi :: RustIntrinsic ||
644
+ bare_fn_ty. abi == Abi :: PlatformIntrinsic ) &&
645
+ tcx. item_name ( def_id) . as_str ( ) == "drop_in_place"
646
+ }
647
+ }
605
648
}
606
649
607
650
fn can_have_local_instance < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
@@ -699,7 +742,6 @@ fn find_drop_glue_neighbors<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
699
742
ty:: TyRef ( ..) |
700
743
ty:: TyFnDef ( ..) |
701
744
ty:: TyFnPtr ( _) |
702
- ty:: TySlice ( _) |
703
745
ty:: TyTrait ( _) => {
704
746
/* nothing to do */
705
747
}
@@ -725,6 +767,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
725
767
}
726
768
}
727
769
ty:: TyBox ( inner_type) |
770
+ ty:: TySlice ( inner_type) |
728
771
ty:: TyArray ( inner_type, _) => {
729
772
let inner_type = glue:: get_drop_glue_type ( scx. tcx ( ) , inner_type) ;
730
773
if glue:: type_needs_drop ( scx. tcx ( ) , inner_type) {
@@ -746,6 +789,8 @@ fn find_drop_glue_neighbors<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
746
789
bug ! ( "encountered unexpected type" ) ;
747
790
}
748
791
}
792
+
793
+
749
794
}
750
795
751
796
fn do_static_dispatch < ' a , ' tcx > ( scx : & SharedCrateContext < ' a , ' tcx > ,
@@ -1187,7 +1232,7 @@ pub enum TransItemState {
1187
1232
}
1188
1233
1189
1234
pub fn collecting_debug_information ( scx : & SharedCrateContext ) -> bool {
1190
- return cfg ! ( debug_assertions) &&
1235
+ return scx . sess ( ) . opts . cg . debug_assertions == Some ( true ) &&
1191
1236
scx. sess ( ) . opts . debugging_opts . print_trans_items . is_some ( ) ;
1192
1237
}
1193
1238
0 commit comments