Skip to content

Commit 6e63e2f

Browse files
committed
Fix copying of fixed length vectors. Closes #2630.
1 parent a569023 commit 6e63e2f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/rustc/middle/trans/base.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,8 +1404,7 @@ fn copy_val_no_check(bcx: block, action: copy_action, dst: ValueRef,
14041404
ret bcx;
14051405
}
14061406
if ty::type_is_nil(t) || ty::type_is_bot(t) { ret bcx; }
1407-
if ty::type_is_boxed(t) || ty::type_is_vec(t) ||
1408-
ty::type_is_unique_box(t) {
1407+
if ty::type_is_boxed(t) || ty::type_is_unique(t) {
14091408
if action == DROP_EXISTING { bcx = drop_ty(bcx, dst, t); }
14101409
Store(bcx, src, dst);
14111410
ret take_ty(bcx, dst, t);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
// error on implicit copies to check fixed length vectors
3+
// are implicitly copyable
4+
#[warn(err_implicit_copies)]
5+
fn main() {
6+
let arr = [1,2,3]/3;
7+
let arr2 = arr;
8+
assert(arr[1] == 2);
9+
assert(arr2[2] == 3);
10+
}

0 commit comments

Comments
 (0)