diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-11-15 16:45:14 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-11-18 10:52:28 +0100 |
| commit | 9cf48d3753e48ec37116d00cd3d4be12b5f71b5a (patch) | |
| tree | 28a5f1638ca628eb49355cf284e464b273144f2f /src/comp/middle | |
| parent | eff7fae7b94b75ee075384b98955f45f56420a5f (diff) | |
| download | rust-9cf48d3753e48ec37116d00cd3d4be12b5f71b5a.tar.gz rust-9cf48d3753e48ec37116d00cd3d4be12b5f71b5a.zip | |
Preparation for kind system overhaul
This goes before a snapshot, so that subsequenct patches can make the transition without breaking the build. Disables kind checking pass, makes parser accept both new and old-style kind annotation. Issue #1177
Diffstat (limited to 'src/comp/middle')
| -rw-r--r-- | src/comp/middle/kind.rs | 32 | ||||
| -rw-r--r-- | src/comp/middle/ty.rs | 22 |
2 files changed, 27 insertions, 27 deletions
diff --git a/src/comp/middle/kind.rs b/src/comp/middle/kind.rs index cffd3fcf7cd..c82792fddf0 100644 --- a/src/comp/middle/kind.rs +++ b/src/comp/middle/kind.rs @@ -84,15 +84,14 @@ * */ -import syntax::{ast, ast_util, visit, codemap}; -import std::{vec, option}; -import ast::{kind, kind_unique, kind_shared, kind_pinned}; +import syntax::ast; +import ast::{kind, kind_sendable, kind_copyable, kind_noncopyable}; fn kind_lteq(a: kind, b: kind) -> bool { alt a { - kind_pinned. { true } - kind_shared. { b != kind_pinned } - kind_unique. { b == kind_unique } + kind_noncopyable. { true } + kind_copyable. { b != kind_noncopyable } + kind_sendable. { b == kind_sendable } } } @@ -102,12 +101,12 @@ fn lower_kind(a: kind, b: kind) -> kind { fn kind_to_str(k: kind) -> str { alt k { - ast::kind_pinned. { "pinned" } - ast::kind_unique. { "unique" } - ast::kind_shared. { "shared" } + ast::kind_sendable. { "sendable" } + ast::kind_copyable. { "copyable" } + ast::kind_noncopyable. { "noncopyable" } } } - +/* fn type_and_kind(tcx: ty::ctxt, e: @ast::expr) -> {ty: ty::t, kind: ast::kind} { let t = ty::expr_ty(tcx, e); @@ -138,8 +137,8 @@ fn demand_kind(tcx: ty::ctxt, sp: codemap::span, t: ty::t, } fn need_shared_lhs_rhs(tcx: ty::ctxt, a: @ast::expr, b: @ast::expr, op: str) { - need_expr_kind(tcx, a, ast::kind_shared, op + " lhs"); - need_expr_kind(tcx, b, ast::kind_shared, op + " rhs"); + need_expr_kind(tcx, a, ast::kind_copyable, op + " lhs"); + need_expr_kind(tcx, b, ast::kind_copyable, op + " rhs"); } /* @@ -296,14 +295,15 @@ fn check_stmt(tcx: ty::ctxt, stmt: @ast::stmt) { _ { /* fall through */ } } } - -fn check_crate(tcx: ty::ctxt, crate: @ast::crate) { - let visit = +*/ +fn check_crate(_tcx: ty::ctxt, _crate: @ast::crate) { + // FIXME stubbed out +/* let visit = visit::mk_simple_visitor(@{visit_expr: bind check_expr(tcx, _), visit_stmt: bind check_stmt(tcx, _) with *visit::default_simple_visitor()}); visit::visit_crate(*crate, (), visit); - tcx.sess.abort_if_errors(); + tcx.sess.abort_if_errors();*/ } // diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index d4aecfbba8a..a039337f5cb 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -993,7 +993,7 @@ fn type_kind(cx: ctxt, ty: t) -> ast::kind { none. {/* fall through */ } } - let result = ast::kind_unique; + let result = ast::kind_noncopyable; // Insert a default in case we loop back on self recursively. cx.kind_cache.insert(ty, result); @@ -1011,21 +1011,21 @@ fn type_kind(cx: ctxt, ty: t) -> ast::kind { // FIXME: obj is broken for now, since we aren't asserting // anything about its fields. ty_obj(_) { - result = kind_shared; + result = kind_copyable; } // FIXME: the environment capture mode is not fully encoded // here yet, leading to weirdness around closure. ty_fn(proto, _, _, _, _) { result = alt proto { - ast::proto_block. { ast::kind_pinned } - ast::proto_shared(_) { ast::kind_shared } - ast::proto_bare. { ast::kind_unique } + ast::proto_block. { ast::kind_noncopyable } + ast::proto_shared(_) { ast::kind_copyable } + ast::proto_bare. { ast::kind_sendable } }; } // Those with refcounts-to-inner raise pinned to shared, // lower unique to shared. Therefore just set result to shared. ty_box(mt) { - result = ast::kind_shared; + result = ast::kind_copyable; } // Pointers and unique containers raise pinned to shared. ty_ptr(tm) | ty_vec(tm) | ty_uniq(tm) { @@ -1044,14 +1044,14 @@ fn type_kind(cx: ctxt, ty: t) -> ast::kind { ty_rec(flds) { for f: field in flds { result = kind::lower_kind(result, type_kind(cx, f.mt.ty)); - if result == ast::kind_pinned { break; } + if result == ast::kind_noncopyable { break; } } } // Tuples lower to the lowest of their members. ty_tup(tys) { for ty: t in tys { result = kind::lower_kind(result, type_kind(cx, ty)); - if result == ast::kind_pinned { break; } + if result == ast::kind_noncopyable { break; } } } // Tags lower to the lowest of their variants. @@ -1062,14 +1062,14 @@ fn type_kind(cx: ctxt, ty: t) -> ast::kind { // Perform any type parameter substitutions. let arg_ty = substitute_type_params(cx, tps, aty); result = kind::lower_kind(result, type_kind(cx, arg_ty)); - if result == ast::kind_pinned { break; } + if result == ast::kind_noncopyable { break; } } - if result == ast::kind_pinned { break; } + if result == ast::kind_noncopyable { break; } } } // Resources are always pinned. ty_res(did, inner, tps) { - result = ast::kind_pinned; + result = ast::kind_noncopyable; } ty_var(_) { fail; |
