Skip to content

Commit 3657119

Browse files
committed
---
yaml --- r: 3345 b: refs/heads/master c: 7432017 h: refs/heads/master i: 3343: 8dd8077 v: v3
1 parent 14cf76f commit 3657119

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
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: f6753be655770cc6fd02db9e5c63131a4536f95e
2+
refs/heads/master: 7432017d5ef4c2adc611bfd8efc6055902a25e4c

trunk/src/comp/middle/trans.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3064,30 +3064,37 @@ tag copy_action { INIT; DROP_EXISTING; }
30643064

30653065
fn copy_val(&@block_ctxt cx, copy_action action, ValueRef dst, ValueRef src,
30663066
&ty::t t) -> result {
3067-
if (ty::type_is_scalar(cx.fcx.lcx.ccx.tcx, t) ||
3068-
ty::type_is_native(cx.fcx.lcx.ccx.tcx, t)) {
3067+
auto ccx = cx.fcx.lcx.ccx;
3068+
// FIXME this is just a clunky stopgap. we should do proper checking in an
3069+
// earlier pass.
3070+
if (!ty::type_is_copyable(ccx.tcx, t)) {
3071+
ccx.sess.span_err(cx.sp, "Copying a non-copyable type.");
3072+
}
3073+
3074+
if (ty::type_is_scalar(ccx.tcx, t) ||
3075+
ty::type_is_native(ccx.tcx, t)) {
30693076
ret rslt(cx, cx.build.Store(src, dst));
3070-
} else if (ty::type_is_nil(cx.fcx.lcx.ccx.tcx, t) ||
3071-
ty::type_is_bot(cx.fcx.lcx.ccx.tcx, t)) {
3077+
} else if (ty::type_is_nil(ccx.tcx, t) ||
3078+
ty::type_is_bot(ccx.tcx, t)) {
30723079
ret rslt(cx, C_nil());
3073-
} else if (ty::type_is_boxed(cx.fcx.lcx.ccx.tcx, t)) {
3080+
} else if (ty::type_is_boxed(ccx.tcx, t)) {
30743081
auto r = take_ty(cx, src, t);
30753082
if (action == DROP_EXISTING) {
30763083
r = drop_ty(r.bcx, r.bcx.build.Load(dst), t);
30773084
}
30783085
ret rslt(r.bcx, r.bcx.build.Store(src, dst));
3079-
} else if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, t) ||
3080-
ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
3086+
} else if (ty::type_is_structural(ccx.tcx, t) ||
3087+
ty::type_has_dynamic_size(ccx.tcx, t)) {
30813088
auto r = take_ty(cx, src, t);
30823089
if (action == DROP_EXISTING) { r = drop_ty(r.bcx, dst, t); }
30833090
r = memmove_ty(r.bcx, dst, src, t);
3084-
if (ty::type_owns_heap_mem(cx.fcx.lcx.ccx.tcx, t)) {
3091+
if (ty::type_owns_heap_mem(ccx.tcx, t)) {
30853092
r = duplicate_heap_parts(cx, dst, t);
30863093
}
30873094
ret r;
30883095
}
3089-
cx.fcx.lcx.ccx.sess.bug("unexpected type in trans::copy_val: " +
3090-
ty_to_str(cx.fcx.lcx.ccx.tcx, t));
3096+
ccx.sess.bug("unexpected type in trans::copy_val: " +
3097+
ty_to_str(ccx.tcx, t));
30913098
}
30923099

30933100

trunk/src/comp/middle/ty.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export type_is_scalar;
170170
export type_is_sequence;
171171
export type_is_signed;
172172
export type_is_structural;
173+
export type_is_copyable;
173174
export type_is_tup_like;
174175
export type_is_str;
175176
export type_owns_heap_mem;
@@ -896,6 +897,13 @@ fn type_is_structural(&ctxt cx, &t ty) -> bool {
896897
}
897898
}
898899

900+
fn type_is_copyable(&ctxt cx, &t ty) -> bool {
901+
ret alt (struct(cx, ty)) {
902+
case (ty_res(_, _)) { false }
903+
case (_) { true }
904+
};
905+
}
906+
899907
fn type_is_sequence(&ctxt cx, &t ty) -> bool {
900908
alt (struct(cx, ty)) {
901909
case (ty_str) { ret true; }

0 commit comments

Comments
 (0)