Skip to content

Commit bcec70b

Browse files
committed
---
yaml --- r: 5579 b: refs/heads/master c: b8bb663 h: refs/heads/master i: 5577: f1d7458 5575: 42b7ac6 v: v3
1 parent 489a1e8 commit bcec70b

File tree

10 files changed

+26
-38
lines changed

10 files changed

+26
-38
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: e50580aa669efc91e5d374e4357bd48dd594169d
2+
refs/heads/master: b8bb663df787511c6b91bf3182b59d140a9c8e02

trunk/src/comp/middle/kind.rs

+4-21
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,6 @@ fn need_shared_lhs_rhs(tcx: ty::ctxt, a: @ast::expr, b: @ast::expr, op: str) {
142142
need_expr_kind(tcx, b, ast::kind_shared, op + " rhs");
143143
}
144144

145-
// Additional checks for copyability that require a little more nuance
146-
fn check_copy(tcx: ty::ctxt, e: @ast::expr) {
147-
alt ty::struct(tcx, ty::expr_ty(tcx, e)) {
148-
// Unique boxes most not contain pinned kinds
149-
ty::ty_uniq(mt) {
150-
demand_kind(tcx, e.span, mt.ty, ast::kind_shared,
151-
"unique box interior");
152-
}
153-
ty::ty_vec(mt) {
154-
demand_kind(tcx, e.span, mt.ty, ast::kind_shared,
155-
"vector interior");
156-
}
157-
_ { }
158-
}
159-
}
160-
161145
fn check_expr(tcx: ty::ctxt, e: @ast::expr) {
162146
alt e.node {
163147

@@ -168,16 +152,13 @@ fn check_expr(tcx: ty::ctxt, e: @ast::expr) {
168152
ast::expr_move(a, b) { need_shared_lhs_rhs(tcx, a, b, "<-"); }
169153
ast::expr_assign(a, b) {
170154
need_shared_lhs_rhs(tcx, a, b, "=");
171-
check_copy(tcx, b);
172155
}
173156
ast::expr_assign_op(_, a, b) {
174157
need_shared_lhs_rhs(tcx, a, b, "op=");
175-
check_copy(tcx, b);
176158
}
177159
ast::expr_swap(a, b) { need_shared_lhs_rhs(tcx, a, b, "<->"); }
178160
ast::expr_copy(a) {
179161
need_expr_kind(tcx, a, ast::kind_shared, "'copy' operand");
180-
check_copy(tcx, a);
181162
}
182163
ast::expr_ret(option::some(a)) {
183164
need_expr_kind(tcx, a, ast::kind_shared, "'ret' operand");
@@ -221,9 +202,11 @@ fn check_stmt(tcx: ty::ctxt, stmt: @ast::stmt) {
221202
need_expr_kind(tcx, expr,
222203
ast::kind_shared,
223204
"local initializer");
224-
check_copy(tcx, expr);
225205
}
226-
_ { /* fall through */ }
206+
option::some({op: ast::init_move., expr}) {
207+
// FIXME: Same as above
208+
}
209+
option::none. { /* fall through */ }
227210
}
228211
}
229212
}

trunk/src/comp/middle/ty.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,14 @@ fn type_kind(cx: ctxt, ty: t) -> ast::kind {
10221022
// Pointers and unique containers raise pinned to shared.
10231023
ty_ptr(tm) | ty_vec(tm) | ty_uniq(tm) {
10241024
let k = type_kind(cx, tm.ty);
1025-
if k == ast::kind_pinned { k = ast::kind_shared; }
1025+
1026+
// FIXME (984) Doing this implies a lot of subtle rules about what can
1027+
// and can't be copied, so I'm going to start by not raising unique of
1028+
// pinned to shared, make sure that's relatively safe, then we can try
1029+
// to make this work.
1030+
1031+
// if k == ast::kind_pinned { k = ast::kind_shared; }
1032+
10261033
result = kind::lower_kind(result, k);
10271034
}
10281035
// Records lower to the lowest of their members.

trunk/src/lib/ptr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ native "rust-intrinsic" mod rusti {
55
fn ptr_offset<T>(ptr: *T, count: uint) -> *T;
66
}
77

8-
fn addr_of<T>(val: T) -> *mutable T { ret rusti::addr_of(val); }
9-
fn offset<T>(ptr: *T, count: uint) -> *T {
8+
fn addr_of<@T>(val: T) -> *mutable T { ret rusti::addr_of(val); }
9+
fn offset<@T>(ptr: *T, count: uint) -> *T {
1010
ret rusti::ptr_offset(ptr, count);
1111
}
1212

13-
fn null<T>() -> *T { ret unsafe::reinterpret_cast(0u); }
13+
fn null<@T>() -> *T { ret unsafe::reinterpret_cast(0u); }

trunk/src/lib/vec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -345,18 +345,18 @@ mod unsafe {
345345
ret rustrt::vec_from_buf_shared(ptr, elts);
346346
}
347347

348-
fn set_len<T>(&v: [T], new_len: uint) {
348+
fn set_len<@T>(&v: [T], new_len: uint) {
349349
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
350350
(**repr).fill = new_len * sys::size_of::<T>();
351351
}
352352

353-
fn to_ptr<T>(v: [T]) -> *T {
353+
fn to_ptr<@T>(v: [T]) -> *T {
354354
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
355355
ret ::unsafe::reinterpret_cast(addr_of((**repr).data));
356356
}
357357
}
358358

359-
fn to_ptr<T>(v: [T]) -> *T { ret unsafe::to_ptr(v); }
359+
fn to_ptr<@T>(v: [T]) -> *T { ret unsafe::to_ptr(v); }
360360

361361
// Local Variables:
362362
// mode: rust;

trunk/src/test/compile-fail/copy-a-resource.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
// error-pattern:Copying a non-copyable type
2-
3-
// This is still not properly checked
4-
// xfail-test
1+
// error-pattern:mismatched kinds
52

63
resource foo(i: int) { }
74

trunk/src/test/compile-fail/pinned-deep-copy.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// xfail-test
2-
// expected error: mismatched kinds
1+
// error-pattern: mismatched kinds
32

43
resource r(i: @mutable int) {
54
*i = *i + 1;

trunk/src/test/run-pass/unique-swap2.rs renamed to trunk/src/test/compile-fail/unique-swap2.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// error-pattern:mismatched kinds
12

23
resource r(i: @mutable int) {
34
*i += 1;
@@ -9,6 +10,8 @@ fn test1() {
910
{
1011
let x <- ~r(i);
1112
let y <- ~r(j);
13+
// This is currently not allowed because ~resource is pinned.
14+
// Note that ~resource is supposed to be shared.
1215
x <-> y;
1316
assert ***x == 200;
1417
assert ***y == 100;

trunk/src/test/compile-fail/unique-vec-res.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// xfail-test
2-
// expected error: mismatched kinds
1+
// error-pattern: mismatched kinds
32

43
resource r(i: @mutable int) {
54
*i = *i + 1;

trunk/src/test/run-pass/unify-return-ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
use std;
55
import std::unsafe;
66

7-
fn null<T>() -> *T { unsafe::reinterpret_cast(0) }
7+
fn null<@T>() -> *T { unsafe::reinterpret_cast(0) }
88

99
fn main() { null::<int>(); }

0 commit comments

Comments
 (0)