Skip to content

Commit e6486dd

Browse files
committed
---
yaml --- r: 6430 b: refs/heads/master c: 1ce3a84 h: refs/heads/master v: v3
1 parent cc6838b commit e6486dd

File tree

3 files changed

+25
-48
lines changed

3 files changed

+25
-48
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 532642f425a4e3c05d848299aec2b95e66e7909c
2+
refs/heads/master: 1ce3a84a8fc6960a50c8f4376d12955026101228

trunk/src/comp/middle/trans.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,8 +1423,8 @@ fn make_drop_glue(bcx: @block_ctxt, v0: ValueRef, t: ty::t) {
14231423
decr_refcnt_maybe_free(bcx, Load(bcx, box_cell), t)
14241424
}
14251425
_ {
1426-
if ty::type_has_pointers(ccx.tcx, t) &&
1427-
ty::type_is_structural(ccx.tcx, t) {
1426+
if ty::type_needs_drop(ccx.tcx, t) &&
1427+
ty::type_is_structural(ccx.tcx, t) {
14281428
iter_structural_ty(bcx, v0, t, drop_ty)
14291429
} else { bcx }
14301430
}
@@ -1916,7 +1916,7 @@ fn call_cmp_glue(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef, t: ty::t,
19161916
}
19171917

19181918
fn take_ty(cx: @block_ctxt, v: ValueRef, t: ty::t) -> @block_ctxt {
1919-
if ty::type_has_pointers(bcx_tcx(cx), t) {
1919+
if ty::type_needs_drop(bcx_tcx(cx), t) {
19201920
ret call_tydesc_glue(cx, v, t, abi::tydesc_field_take_glue);
19211921
}
19221922
ret cx;
@@ -1935,9 +1935,6 @@ fn drop_ty_immediate(bcx: @block_ctxt, v: ValueRef, t: ty::t) -> @block_ctxt {
19351935
ret free_ty(bcx, v, t);
19361936
}
19371937
ty::ty_box(_) { ret decr_refcnt_maybe_free(bcx, v, t); }
1938-
// FIXME A ty_ptr pointing at something that needs drop glue is somehow
1939-
// marked as needing drop glue. This is probably a mistake.
1940-
ty::ty_ptr(_) { ret bcx; }
19411938
}
19421939
}
19431940

@@ -1954,7 +1951,7 @@ fn take_ty_immediate(bcx: @block_ctxt, v: ValueRef, t: ty::t) -> result {
19541951
}
19551952

19561953
fn free_ty(cx: @block_ctxt, v: ValueRef, t: ty::t) -> @block_ctxt {
1957-
if ty::type_has_pointers(bcx_tcx(cx), t) {
1954+
if ty::type_needs_drop(bcx_tcx(cx), t) {
19581955
ret call_tydesc_glue(cx, v, t, abi::tydesc_field_free_glue);
19591956
}
19601957
ret cx;

trunk/src/comp/middle/ty.rs

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ export type_kind;
144144
export type_err;
145145
export type_err_to_str;
146146
export type_has_dynamic_size;
147-
export type_has_pointers;
148147
export type_needs_drop;
149148
export type_is_bool;
150149
export type_is_bot;
@@ -213,7 +212,7 @@ type ctxt =
213212
tcache: type_cache,
214213
rcache: creader_cache,
215214
short_names_cache: hashmap<t, @str>,
216-
has_pointer_cache: hashmap<t, bool>,
215+
needs_drop_cache: hashmap<t, bool>,
217216
kind_cache: hashmap<t, ast::kind>,
218217
ast_ty_to_ty_cache: hashmap<@ast::ty, option::t<t>>};
219218

@@ -400,7 +399,7 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map,
400399
tcache: tcache,
401400
rcache: mk_rcache(),
402401
short_names_cache: map::mk_hashmap(ty::hash_ty, ty::eq_ty),
403-
has_pointer_cache: map::mk_hashmap(ty::hash_ty, ty::eq_ty),
402+
needs_drop_cache: map::mk_hashmap(ty::hash_ty, ty::eq_ty),
404403
kind_cache: map::mk_hashmap(ty::hash_ty, ty::eq_ty),
405404
ast_ty_to_ty_cache:
406405
map::mk_hashmap(ast_util::hash_ty, ast_util::eq_ty)};
@@ -925,63 +924,44 @@ fn type_is_immediate(cx: ctxt, ty: t) -> bool {
925924
type_is_unique(cx, ty) || type_is_native(cx, ty);
926925
}
927926

928-
fn type_has_pointers(cx: ctxt, ty: t) -> bool {
929-
alt cx.has_pointer_cache.find(ty) {
927+
fn type_needs_drop(cx: ctxt, ty: t) -> bool {
928+
alt cx.needs_drop_cache.find(ty) {
930929
some(result) { ret result; }
931930
none. {/* fall through */ }
932931
}
933932

934-
let result = false;
935-
alt struct(cx, ty) {
933+
let accum = false;
934+
let result = alt struct(cx, ty) {
936935
// scalar types
937-
ty_nil. {/* no-op */ }
938-
ty_bot. {/* no-op */ }
939-
ty_bool. {/* no-op */ }
940-
ty_int. {/* no-op */ }
941-
ty_float. {/* no-op */ }
942-
ty_uint. {/* no-op */ }
943-
ty_machine(_) {/* no-op */ }
944-
ty_char. {/* no-op */ }
945-
ty_type. {/* no-op */ }
946-
ty_native(_) {/* no-op */ }
936+
ty_nil. | ty_bot. | ty_bool. | ty_int. | ty_float. | ty_uint. |
937+
ty_machine(_) | ty_char. | ty_type. | ty_native(_) | ty_ptr(_) { false }
947938
ty_rec(flds) {
948-
for f: field in flds {
949-
if type_has_pointers(cx, f.mt.ty) { result = true; break; }
950-
}
939+
for f in flds { if type_needs_drop(cx, f.mt.ty) { accum = true; } }
940+
accum
951941
}
952942
ty_tup(elts) {
953-
for m in elts { if type_has_pointers(cx, m) { result = true; } }
943+
for m in elts { if type_needs_drop(cx, m) { accum = true; } }
944+
accum
954945
}
955946
ty_tag(did, tps) {
956947
let variants = tag_variants(cx, did);
957-
for variant: variant_info in variants {
958-
for aty: t in variant.args {
948+
for variant in variants {
949+
for aty in variant.args {
959950
// Perform any type parameter substitutions.
960951
let arg_ty = substitute_type_params(cx, tps, aty);
961-
if type_has_pointers(cx, arg_ty) { result = true; break; }
952+
if type_needs_drop(cx, arg_ty) { accum = true; }
962953
}
963-
if result { break; }
954+
if accum { break; }
964955
}
956+
accum
965957
}
966-
ty_res(did, inner, tps) {
967-
result =
968-
type_has_pointers(cx, substitute_type_params(cx, tps, inner));
969-
}
970-
_ { result = true; }
971-
}
958+
_ { true }
959+
};
972960

973-
cx.has_pointer_cache.insert(ty, result);
961+
cx.needs_drop_cache.insert(ty, result);
974962
ret result;
975963
}
976964

977-
fn type_needs_drop(cx: ctxt, ty: t) -> bool {
978-
ret alt struct(cx, ty) {
979-
ty_res(_, _, _) { true }
980-
ty_param(_, _) { true }
981-
_ { type_has_pointers(cx, ty) }
982-
};
983-
}
984-
985965
fn kind_lteq(a: kind, b: kind) -> bool {
986966
alt a {
987967
kind_noncopyable. { true }

0 commit comments

Comments
 (0)