diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-09-27 14:50:55 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-09-27 16:03:10 -0700 |
| commit | b8bb663df787511c6b91bf3182b59d140a9c8e02 (patch) | |
| tree | 157792f952836504216eb4ba2715327a7afd361a /src/comp | |
| parent | e50580aa669efc91e5d374e4357bd48dd594169d (diff) | |
Don't ever raise unique kinds of pinned kinds to shared (again)
So *resource, ~resource, [resource] are all pinned. This is counter to the design of the kind system, but this way is a much clearer path to type safety. Once we've established a good baseline with lots of tests, then we can try to make raising pinned kinds work.
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/kind.rs | 25 | ||||
| -rw-r--r-- | src/comp/middle/ty.rs | 9 |
2 files changed, 12 insertions, 22 deletions
diff --git a/src/comp/middle/kind.rs b/src/comp/middle/kind.rs index 3880d4c3601..c7f37e95c8c 100644 --- a/src/comp/middle/kind.rs +++ b/src/comp/middle/kind.rs @@ -142,22 +142,6 @@ fn need_shared_lhs_rhs(tcx: ty::ctxt, a: @ast::expr, b: @ast::expr, op: str) { need_expr_kind(tcx, b, ast::kind_shared, op + " rhs"); } -// Additional checks for copyability that require a little more nuance -fn check_copy(tcx: ty::ctxt, e: @ast::expr) { - alt ty::struct(tcx, ty::expr_ty(tcx, e)) { - // Unique boxes most not contain pinned kinds - ty::ty_uniq(mt) { - demand_kind(tcx, e.span, mt.ty, ast::kind_shared, - "unique box interior"); - } - ty::ty_vec(mt) { - demand_kind(tcx, e.span, mt.ty, ast::kind_shared, - "vector interior"); - } - _ { } - } -} - fn check_expr(tcx: ty::ctxt, e: @ast::expr) { alt e.node { @@ -168,16 +152,13 @@ fn check_expr(tcx: ty::ctxt, e: @ast::expr) { ast::expr_move(a, b) { need_shared_lhs_rhs(tcx, a, b, "<-"); } ast::expr_assign(a, b) { need_shared_lhs_rhs(tcx, a, b, "="); - check_copy(tcx, b); } ast::expr_assign_op(_, a, b) { need_shared_lhs_rhs(tcx, a, b, "op="); - check_copy(tcx, b); } ast::expr_swap(a, b) { need_shared_lhs_rhs(tcx, a, b, "<->"); } ast::expr_copy(a) { need_expr_kind(tcx, a, ast::kind_shared, "'copy' operand"); - check_copy(tcx, a); } ast::expr_ret(option::some(a)) { need_expr_kind(tcx, a, ast::kind_shared, "'ret' operand"); @@ -221,9 +202,11 @@ fn check_stmt(tcx: ty::ctxt, stmt: @ast::stmt) { need_expr_kind(tcx, expr, ast::kind_shared, "local initializer"); - check_copy(tcx, expr); } - _ { /* fall through */ } + option::some({op: ast::init_move., expr}) { + // FIXME: Same as above + } + option::none. { /* fall through */ } } } } diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 5dda7e74a99..3e76ce2f93e 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1022,7 +1022,14 @@ fn type_kind(cx: ctxt, ty: t) -> ast::kind { // Pointers and unique containers raise pinned to shared. ty_ptr(tm) | ty_vec(tm) | ty_uniq(tm) { let k = type_kind(cx, tm.ty); - if k == ast::kind_pinned { k = ast::kind_shared; } + + // FIXME (984) Doing this implies a lot of subtle rules about what can + // and can't be copied, so I'm going to start by not raising unique of + // pinned to shared, make sure that's relatively safe, then we can try + // to make this work. + + // if k == ast::kind_pinned { k = ast::kind_shared; } + result = kind::lower_kind(result, k); } // Records lower to the lowest of their members. |
