Skip to content

Commit b8715b6

Browse files
committed
---
yaml --- r: 107993 b: refs/heads/dist-snap c: 2bf575c h: refs/heads/master i: 107991: 7dc3610 v: v3
1 parent 00acfbe commit b8715b6

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: f64fdf524a434f0e5cd0bc91d09c144723f3c90d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: dd21a51d294ad9843d61b7f2016957a279b0d64f
9+
refs/heads/dist-snap: 2bf575c86fd3c053df83b90862441fec71c7a622
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/middle/trans/glue.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use middle::trans::machine::*;
3030
use middle::trans::reflect;
3131
use middle::trans::tvec;
3232
use middle::trans::type_::Type;
33-
use middle::trans::type_of::type_of;
33+
use middle::trans::type_of::{type_of, sizing_type_of};
3434
use middle::ty;
3535
use util::ppaux::ty_to_short_str;
3636
use util::ppaux;
@@ -100,23 +100,29 @@ pub fn lazily_emit_all_tydesc_glue(ccx: @CrateContext,
100100
lazily_emit_tydesc_glue(ccx, abi::tydesc_field_visit_glue, static_ti);
101101
}
102102

103-
fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t {
103+
fn get_glue_type(ccx: &CrateContext, field: uint, t: ty::t) -> ty::t {
104+
let tcx = ccx.tcx;
104105
if field == abi::tydesc_field_drop_glue {
105106
if !ty::type_needs_drop(tcx, t) {
106-
return ty::mk_nil();
107+
return ty::mk_i8();
107108
}
108109
match ty::get(t).sty {
109-
ty::ty_box(typ)
110-
if !ty::type_needs_drop(tcx, typ) =>
111-
return ty::mk_box(tcx, ty::mk_nil()),
112-
113-
ty::ty_uniq(typ)
114-
if !ty::type_needs_drop(tcx, typ) =>
115-
return ty::mk_uniq(tcx, ty::mk_nil()),
110+
ty::ty_box(typ) if !ty::type_needs_drop(tcx, typ) =>
111+
return ty::mk_box(tcx, ty::mk_i8()),
112+
113+
ty::ty_uniq(typ) if !ty::type_needs_drop(tcx, typ) => {
114+
let llty = sizing_type_of(ccx, typ);
115+
// Unique boxes do not allocate for zero-size types. The standard library may assume
116+
// that `free` is never called on the pointer returned for `~ZeroSizeType`.
117+
if llsize_of_alloc(ccx, llty) == 0 {
118+
return ty::mk_i8();
119+
} else {
120+
return ty::mk_uniq(tcx, ty::mk_i8());
121+
}
122+
}
116123

117-
ty::ty_vec(mt, ty::vstore_uniq)
118-
if !ty::type_needs_drop(tcx, mt.ty) =>
119-
return ty::mk_uniq(tcx, ty::mk_nil()),
124+
ty::ty_vec(mt, ty::vstore_uniq) if !ty::type_needs_drop(tcx, mt.ty) =>
125+
return ty::mk_uniq(tcx, ty::mk_i8()),
120126

121127
_ => {}
122128
}
@@ -128,7 +134,7 @@ fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t {
128134
pub fn lazily_emit_tydesc_glue(ccx: @CrateContext, field: uint, ti: @tydesc_info) {
129135
let _icx = push_ctxt("lazily_emit_tydesc_glue");
130136

131-
let simpl = simplified_glue_type(ccx.tcx, field, ti.ty);
137+
let simpl = get_glue_type(ccx, field, ti.ty);
132138
if simpl != ti.ty {
133139
let _icx = push_ctxt("lazily_emit_simplified_tydesc_glue");
134140
let simpl_ti = get_tydesc(ccx, simpl);
@@ -204,7 +210,7 @@ pub fn call_tydesc_glue_full(bcx: &Block, v: ValueRef, tydesc: ValueRef,
204210
PointerCast(bcx, v, Type::i8p())
205211
} else {
206212
let ty = static_ti.unwrap().ty;
207-
let simpl = simplified_glue_type(ccx.tcx, field, ty);
213+
let simpl = get_glue_type(ccx, field, ty);
208214
if simpl != ty {
209215
PointerCast(bcx, v, type_of(ccx, simpl).ptr_to())
210216
} else {

0 commit comments

Comments
 (0)