diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2011-08-23 15:58:53 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2011-08-23 15:58:53 -0700 |
| commit | c011f131446d3e2cbbb9266bfefc9fd9637f9bd0 (patch) | |
| tree | 03c739a21ab4e75b5d3c83d7d2d5c84f7daa0bcf /src/comp | |
| parent | a3c8d4a5a58b42db6b8795980992e1063e84f59f (diff) | |
Add kind-checking for assign-op, copy, ret, be, fail exprs. Fix caught kinding-violations in rustc and libstd.
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/driver/rustc.rs | 2 | ||||
| -rw-r--r-- | src/comp/front/attr.rs | 2 | ||||
| -rw-r--r-- | src/comp/front/test.rs | 2 | ||||
| -rw-r--r-- | src/comp/middle/kind.rs | 14 | ||||
| -rw-r--r-- | src/comp/syntax/ast_util.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/util/interner.rs | 2 |
7 files changed, 20 insertions, 6 deletions
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index a1981e1d283..ded36db2cf8 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -108,7 +108,7 @@ fn parse_input_src(sess: session::session, cfg: &ast::crate_cfg, infile: str) ret {crate: crate, src: src}; } -fn time<T>(do_it: bool, what: str, thunk: fn() -> T) -> T { +fn time<@T>(do_it: bool, what: str, thunk: fn() -> T) -> T { if !do_it { ret thunk(); } let start = std::time::precise_time_s(); let rv = thunk(); diff --git a/src/comp/front/attr.rs b/src/comp/front/attr.rs index e199d10fbd1..5701ff33f97 100644 --- a/src/comp/front/attr.rs +++ b/src/comp/front/attr.rs @@ -189,7 +189,7 @@ fn require_unique_names(sess: &session::session, metas: &[@ast::meta_item]) { } } -fn span<T>(item: &T) -> ast::spanned<T> { +fn span<@T>(item: &T) -> ast::spanned<T> { ret {node: item, span: ast_util::dummy_sp()}; } diff --git a/src/comp/front/test.rs b/src/comp/front/test.rs index d9cda6e601a..8e0b71caf84 100644 --- a/src/comp/front/test.rs +++ b/src/comp/front/test.rs @@ -170,7 +170,7 @@ fn mk_test_module(cx: &test_ctxt) -> @ast::item { ret @item; } -fn nospan<T>(t: &T) -> ast::spanned<T> { +fn nospan<@T>(t: &T) -> ast::spanned<T> { ret {node: t, span: dummy_sp()}; } diff --git a/src/comp/middle/kind.rs b/src/comp/middle/kind.rs index 4ffdcc95ff3..9a0d251e44e 100644 --- a/src/comp/middle/kind.rs +++ b/src/comp/middle/kind.rs @@ -76,6 +76,7 @@ import syntax::ast_util; import syntax::visit; import std::vec; +import std::option; import ast::kind; import ast::kind_unique; @@ -135,7 +136,20 @@ fn check_expr(tcx: &ty::ctxt, e: &@ast::expr) { alt e.node { ast::expr_move(a, b) { need_shared_lhs_rhs(tcx, a, b, "<-"); } ast::expr_assign(a, b) { need_shared_lhs_rhs(tcx, a, b, "="); } + ast::expr_assign_op(_, a, b) { need_shared_lhs_rhs(tcx, a, b, "op="); } 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"); + } + ast::expr_ret(option::some(a)) { + need_expr_kind(tcx, a, ast::kind_shared, "'ret' operand"); + } + ast::expr_be(a) { + need_expr_kind(tcx, a, ast::kind_shared, "'be' operand"); + } + ast::expr_fail(option::some(a)) { + need_expr_kind(tcx, a, ast::kind_shared, "'fail' operand"); + } ast::expr_call(callee, _) { let tpt = ty::expr_ty_params_and_ty(tcx, callee); diff --git a/src/comp/syntax/ast_util.rs b/src/comp/syntax/ast_util.rs index e3b16702b76..e89889fa027 100644 --- a/src/comp/syntax/ast_util.rs +++ b/src/comp/syntax/ast_util.rs @@ -3,7 +3,7 @@ import std::option; import codemap::span; import ast::*; -fn respan<T>(sp: &span, t: &T) -> spanned<T> { ret {node: t, span: sp}; } +fn respan<@T>(sp: &span, t: &T) -> spanned<T> { ret {node: t, span: sp}; } /* assuming that we're not in macro expansion */ fn mk_sp(lo: uint, hi: uint) -> span { diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 495d1372d79..aa553e32e39 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -222,7 +222,7 @@ fn expect_gt(p: &parser) { } } -fn spanned<T>(lo: uint, hi: uint, node: &T) -> spanned<T> { +fn spanned<@T>(lo: uint, hi: uint, node: &T) -> spanned<T> { ret {node: node, span: ast_util::mk_sp(lo, hi)}; } diff --git a/src/comp/syntax/util/interner.rs b/src/comp/syntax/util/interner.rs index 31656886a45..3d1a495fb2e 100644 --- a/src/comp/syntax/util/interner.rs +++ b/src/comp/syntax/util/interner.rs @@ -33,7 +33,7 @@ fn intern<@T>(itr: &interner<T>, val: &T) -> uint { } } -fn get<T>(itr: &interner<T>, idx: uint) -> T { ret itr.vect[idx]; } +fn get<@T>(itr: &interner<T>, idx: uint) -> T { ret itr.vect[idx]; } fn len<T>(itr: &interner<T>) -> uint { ret vec::len(itr.vect); } |
