Skip to content

Commit 0a89c35

Browse files
---
yaml --- r: 277831 b: refs/heads/try c: 75bf617 h: refs/heads/master i: 277829: b2e7186 277827: ba3dc93 277823: 6f6f663
1 parent 27eab1c commit 0a89c35

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: 3f74c6afe0821778047ec46f29b815fc30f7ec1f
4+
refs/heads/try: 75bf6173e5f549a8345c092d4c2fe9ba896253e0
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc_trans/collector.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
390390
TransItem::Static(node_id) => {
391391
let def_id = ccx.tcx().map.local_def_id(node_id);
392392
let ty = ccx.tcx().lookup_item_type(def_id).ty;
393-
let ty = glue::get_drop_glue_type(ccx, ty);
393+
let ty = glue::get_drop_glue_type(ccx.tcx(), ty);
394394
neighbors.push(TransItem::DropGlue(DropGlueKind::Ty(ty)));
395395
recursion_depth_reset = None;
396396
}
@@ -554,7 +554,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
554554
self.param_substs,
555555
&ty);
556556
let ty = self.ccx.tcx().erase_regions(&ty);
557-
let ty = glue::get_drop_glue_type(self.ccx, ty);
557+
let ty = glue::get_drop_glue_type(self.ccx.tcx(), ty);
558558
self.output.push(TransItem::DropGlue(DropGlueKind::Ty(ty)));
559559
}
560560

@@ -740,7 +740,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
740740
let field_type = monomorphize::apply_param_substs(ccx.tcx(),
741741
substs,
742742
&field.unsubst_ty());
743-
let field_type = glue::get_drop_glue_type(ccx, field_type);
743+
let field_type = glue::get_drop_glue_type(ccx.tcx(), field_type);
744744

745745
if glue::type_needs_drop(ccx.tcx(), field_type) {
746746
output.push(TransItem::DropGlue(DropGlueKind::Ty(field_type)));
@@ -749,22 +749,22 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
749749
}
750750
ty::TyClosure(_, ref substs) => {
751751
for upvar_ty in &substs.upvar_tys {
752-
let upvar_ty = glue::get_drop_glue_type(ccx, upvar_ty);
752+
let upvar_ty = glue::get_drop_glue_type(ccx.tcx(), upvar_ty);
753753
if glue::type_needs_drop(ccx.tcx(), upvar_ty) {
754754
output.push(TransItem::DropGlue(DropGlueKind::Ty(upvar_ty)));
755755
}
756756
}
757757
}
758758
ty::TyBox(inner_type) |
759759
ty::TyArray(inner_type, _) => {
760-
let inner_type = glue::get_drop_glue_type(ccx, inner_type);
760+
let inner_type = glue::get_drop_glue_type(ccx.tcx(), inner_type);
761761
if glue::type_needs_drop(ccx.tcx(), inner_type) {
762762
output.push(TransItem::DropGlue(DropGlueKind::Ty(inner_type)));
763763
}
764764
}
765765
ty::TyTuple(ref args) => {
766766
for arg in args {
767-
let arg = glue::get_drop_glue_type(ccx, arg);
767+
let arg = glue::get_drop_glue_type(ccx.tcx(), arg);
768768
if glue::type_needs_drop(ccx.tcx(), arg) {
769769
output.push(TransItem::DropGlue(DropGlueKind::Ty(arg)));
770770
}
@@ -1079,7 +1079,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
10791079
def_id_to_string(self.ccx.tcx(),
10801080
self.ccx.tcx().map.local_def_id(item.id)));
10811081

1082-
let ty = glue::get_drop_glue_type(self.ccx, ty);
1082+
let ty = glue::get_drop_glue_type(self.ccx.tcx(), ty);
10831083
self.output.push(TransItem::DropGlue(DropGlueKind::Ty(ty)));
10841084
}
10851085
}

branches/try/src/librustc_trans/glue.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use llvm;
1919
use llvm::{ValueRef, get_param};
2020
use middle::lang_items::ExchangeFreeFnLangItem;
2121
use rustc::ty::subst::{Substs};
22-
use rustc::traits;
22+
use rustc::{infer, traits};
2323
use rustc::ty::{self, Ty, TyCtxt};
2424
use abi::{Abi, FnType};
2525
use adt;
@@ -92,13 +92,12 @@ pub fn type_needs_drop<'tcx>(tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
9292
tcx.type_needs_drop_given_env(ty, &tcx.empty_parameter_environment())
9393
}
9494

95-
pub fn get_drop_glue_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
96-
t: Ty<'tcx>) -> Ty<'tcx> {
97-
let tcx = ccx.tcx();
95+
pub fn get_drop_glue_type<'tcx>(tcx: &TyCtxt<'tcx>,
96+
t: Ty<'tcx>) -> Ty<'tcx> {
9897
// Even if there is no dtor for t, there might be one deeper down and we
9998
// might need to pass in the vtable ptr.
10099
if !type_is_sized(tcx, t) {
101-
return ccx.tcx().erase_regions(&t);
100+
return tcx.erase_regions(&t);
102101
}
103102

104103
// FIXME (#22815): note that type_needs_drop conservatively
@@ -116,15 +115,18 @@ pub fn get_drop_glue_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
116115
match t.sty {
117116
ty::TyBox(typ) if !type_needs_drop(&tcx, typ)
118117
&& type_is_sized(tcx, typ) => {
119-
let llty = sizing_type_of(ccx, typ);
120-
// `Box<ZeroSizeType>` does not allocate.
121-
if llsize_of_alloc(ccx, llty) == 0 {
118+
let infcx = infer::normalizing_infer_ctxt(tcx,
119+
&tcx.tables,
120+
traits::ProjectionMode::Any);
121+
let layout = t.layout(&infcx).unwrap();
122+
if layout.size(&tcx.data_layout).bytes() == 0 {
123+
// `Box<ZeroSizeType>` does not allocate.
122124
tcx.types.i8
123125
} else {
124-
ccx.tcx().erase_regions(&t)
126+
tcx.erase_regions(&t)
125127
}
126128
}
127-
_ => ccx.tcx().erase_regions(&t)
129+
_ => tcx.erase_regions(&t)
128130
}
129131
}
130132

@@ -154,7 +156,7 @@ pub fn drop_ty_core<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
154156
DropGlueKind::Ty(t)
155157
};
156158
let glue = get_drop_glue_core(ccx, g);
157-
let glue_type = get_drop_glue_type(ccx, t);
159+
let glue_type = get_drop_glue_type(ccx.tcx(), t);
158160
let ptr = if glue_type != t {
159161
PointerCast(bcx, v, type_of(ccx, glue_type).ptr_to())
160162
} else {
@@ -231,7 +233,7 @@ impl<'tcx> DropGlueKind<'tcx> {
231233
fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
232234
g: DropGlueKind<'tcx>) -> ValueRef {
233235
debug!("make drop glue for {:?}", g);
234-
let g = g.map_ty(|t| get_drop_glue_type(ccx, t));
236+
let g = g.map_ty(|t| get_drop_glue_type(ccx.tcx(), t));
235237
debug!("drop glue type {:?}", g);
236238
match ccx.drop_glues().borrow().get(&g) {
237239
Some(&glue) => return glue,

branches/try/src/librustc_trans/mir/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
136136
return;
137137
}
138138
let drop_fn = glue::get_drop_glue(bcx.ccx(), ty);
139-
let drop_ty = glue::get_drop_glue_type(bcx.ccx(), ty);
139+
let drop_ty = glue::get_drop_glue_type(bcx.tcx(), ty);
140140
let llvalue = if drop_ty != ty {
141141
bcx.pointercast(lvalue.llval, type_of::type_of(bcx.ccx(), drop_ty).ptr_to())
142142
} else {

0 commit comments

Comments
 (0)