Use different syntax for checks that matter to typestate
This giant commit changes the syntax of Rust to use "assert" for "check" expressions that didn't mean anything to the typestate system, and continue using "check" for checks that are used as part of typestate checking. Most of the changes are just replacing "check" with "assert" in test cases and rustc.
This commit is contained in:
parent
870435caf5
commit
aa25f22f19
182 changed files with 1256 additions and 1239 deletions
|
@ -621,7 +621,7 @@ fn parse_path(parser p, greed g) -> ast.path {
|
|||
if (p.peek() == token.DOT) {
|
||||
if (g == GREEDY) {
|
||||
p.bump();
|
||||
check (is_ident(p.peek()));
|
||||
assert (is_ident(p.peek()));
|
||||
} else {
|
||||
more = false;
|
||||
}
|
||||
|
@ -816,19 +816,22 @@ fn parse_bottom_expr(parser p) -> @ast.expr {
|
|||
ex = ast.expr_log(0, e, ast.ann_none);
|
||||
}
|
||||
|
||||
case (token.ASSERT) {
|
||||
p.bump();
|
||||
auto e = parse_expr(p);
|
||||
auto hi = e.span.hi;
|
||||
ex = ast.expr_assert(e, ast.ann_none);
|
||||
}
|
||||
|
||||
case (token.CHECK) {
|
||||
p.bump();
|
||||
alt (p.peek()) {
|
||||
case (token.LPAREN) {
|
||||
auto e = parse_expr(p);
|
||||
auto hi = e.span.hi;
|
||||
ex = ast.expr_check_expr(e, ast.ann_none);
|
||||
}
|
||||
case (_) {
|
||||
p.get_session().unimpl("constraint-check stmt");
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Should be a predicate (pure boolean function) applied to
|
||||
arguments that are all either slot variables or literals.
|
||||
but the typechecker enforces that. */
|
||||
auto e = parse_expr(p);
|
||||
auto hi = e.span.hi;
|
||||
ex = ast.expr_check(e, ast.ann_none);
|
||||
}
|
||||
|
||||
case (token.RET) {
|
||||
p.bump();
|
||||
|
@ -937,7 +940,7 @@ fn expand_syntax_ext(parser p, ast.span sp,
|
|||
&ast.path path, vec[@ast.expr] args,
|
||||
option.t[str] body) -> ast.expr_ {
|
||||
|
||||
check (_vec.len[ast.ident](path.node.idents) > 0u);
|
||||
assert (_vec.len[ast.ident](path.node.idents) > 0u);
|
||||
auto extname = path.node.idents.(0);
|
||||
if (_str.eq(extname, "fmt")) {
|
||||
auto expanded = extfmt.expand_syntax_ext(args, body);
|
||||
|
@ -1673,7 +1676,8 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool {
|
|||
case (ast.expr_put(_,_)) { ret true; }
|
||||
case (ast.expr_be(_,_)) { ret true; }
|
||||
case (ast.expr_log(_,_,_)) { ret true; }
|
||||
case (ast.expr_check_expr(_,_)) { ret true; }
|
||||
case (ast.expr_check(_,_)) { ret true; }
|
||||
case (ast.expr_assert(_,_)) { ret true; }
|
||||
}
|
||||
}
|
||||
// We should not be calling this on a cdir.
|
||||
|
@ -2157,24 +2161,24 @@ fn parse_item(parser p) -> @ast.item {
|
|||
|
||||
alt (p.peek()) {
|
||||
case (token.CONST) {
|
||||
check (lyr == ast.layer_value);
|
||||
assert (lyr == ast.layer_value);
|
||||
ret parse_item_const(p);
|
||||
}
|
||||
|
||||
case (token.FN) {
|
||||
check (lyr == ast.layer_value);
|
||||
assert (lyr == ast.layer_value);
|
||||
ret parse_item_fn_or_iter(p);
|
||||
}
|
||||
case (token.ITER) {
|
||||
check (lyr == ast.layer_value);
|
||||
assert (lyr == ast.layer_value);
|
||||
ret parse_item_fn_or_iter(p);
|
||||
}
|
||||
case (token.MOD) {
|
||||
check (lyr == ast.layer_value);
|
||||
assert (lyr == ast.layer_value);
|
||||
ret parse_item_mod(p);
|
||||
}
|
||||
case (token.NATIVE) {
|
||||
check (lyr == ast.layer_value);
|
||||
assert (lyr == ast.layer_value);
|
||||
ret parse_item_native_mod(p);
|
||||
}
|
||||
case (token.TYPE) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue