librustc: Stop parsing assert
.
This commit is contained in:
parent
d7e74b5e91
commit
9a17ef9b52
@ -109,8 +109,7 @@ pub pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
|
||||
| ast::expr_match(*) | ast::expr_while(*) => { false }
|
||||
|
||||
// https://github.com/mozilla/rust/issues/929
|
||||
ast::expr_cast(*) | ast::expr_assert(*) |
|
||||
ast::expr_binary(*) | ast::expr_assign(*) |
|
||||
ast::expr_cast(*) | ast::expr_binary(*) | ast::expr_assign(*) |
|
||||
ast::expr_assign_op(*) => { false }
|
||||
|
||||
ast::expr_ret(option::None) => { false }
|
||||
|
@ -617,11 +617,11 @@ fn visit_expr(expr: @expr, &&self: @mut IrMaps, vt: vt<@mut IrMaps>) {
|
||||
// otherwise, live nodes are not required:
|
||||
expr_index(*) | expr_field(*) | expr_vstore(*) | expr_vec(*) |
|
||||
expr_call(*) | expr_method_call(*) | expr_tup(*) | expr_log(*) |
|
||||
expr_binary(*) | expr_assert(*) | expr_addr_of(*) | expr_copy(*) |
|
||||
expr_loop_body(*) | expr_do_body(*) | expr_cast(*) | expr_unary(*) |
|
||||
expr_break(_) | expr_again(_) | expr_lit(_) | expr_ret(*) |
|
||||
expr_block(*) | expr_assign(*) | expr_swap(*) | expr_assign_op(*) |
|
||||
expr_mac(*) | expr_struct(*) | expr_repeat(*) | expr_paren(*) => {
|
||||
expr_binary(*) | expr_addr_of(*) | expr_copy(*) | expr_loop_body(*) |
|
||||
expr_do_body(*) | expr_cast(*) | expr_unary(*) | expr_break(_) |
|
||||
expr_again(_) | expr_lit(_) | expr_ret(*) | expr_block(*) |
|
||||
expr_assign(*) | expr_swap(*) | expr_assign_op(*) | expr_mac(*) |
|
||||
expr_struct(*) | expr_repeat(*) | expr_paren(*) => {
|
||||
visit::visit_expr(expr, self, vt);
|
||||
}
|
||||
}
|
||||
@ -1332,7 +1332,6 @@ fn propagate_through_expr(&self, expr: @expr, succ: LiveNode)
|
||||
self.propagate_through_exprs(~[l, r], succ)
|
||||
}
|
||||
|
||||
expr_assert(e) |
|
||||
expr_addr_of(_, e) |
|
||||
expr_copy(e) |
|
||||
expr_loop_body(e) |
|
||||
@ -1493,8 +1492,9 @@ fn propagate_through_loop(&self, expr: @expr,
|
||||
// repeat until fixed point is reached:
|
||||
while self.merge_from_succ(ln, body_ln, first_merge) {
|
||||
first_merge = false;
|
||||
fail_unless!(cond_ln == self.propagate_through_opt_expr(cond, ln));
|
||||
assert body_ln == self.with_loop_nodes(expr.id, succ, ln,
|
||||
fail_unless!(cond_ln == self.propagate_through_opt_expr(cond,
|
||||
ln));
|
||||
fail_unless!(body_ln == self.with_loop_nodes(expr.id, succ, ln,
|
||||
|| {
|
||||
self.propagate_through_block(body, cond_ln)
|
||||
}));
|
||||
@ -1611,11 +1611,11 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
|
||||
expr_call(*) | expr_method_call(*) | expr_if(*) | expr_match(*) |
|
||||
expr_while(*) | expr_loop(*) | expr_index(*) | expr_field(*) |
|
||||
expr_vstore(*) | expr_vec(*) | expr_tup(*) | expr_log(*) |
|
||||
expr_binary(*) | expr_assert(*) | expr_copy(*) | expr_loop_body(*) |
|
||||
expr_do_body(*) | expr_cast(*) | expr_unary(*) | expr_ret(*) |
|
||||
expr_break(*) | expr_again(*) | expr_lit(_) | expr_block(*) |
|
||||
expr_swap(*) | expr_mac(*) | expr_addr_of(*) | expr_struct(*) |
|
||||
expr_repeat(*) | expr_paren(*) => {
|
||||
expr_binary(*) | expr_copy(*) | expr_loop_body(*) | expr_do_body(*) |
|
||||
expr_cast(*) | expr_unary(*) | expr_ret(*) | expr_break(*) |
|
||||
expr_again(*) | expr_lit(_) | expr_block(*) | expr_swap(*) |
|
||||
expr_mac(*) | expr_addr_of(*) | expr_struct(*) | expr_repeat(*) |
|
||||
expr_paren(*) => {
|
||||
visit::visit_expr(expr, self, vt);
|
||||
}
|
||||
}
|
||||
|
@ -437,19 +437,17 @@ fn cat_expr_unadjusted(&self, expr: @ast::expr) -> cmt {
|
||||
|
||||
ast::expr_paren(e) => self.cat_expr_unadjusted(e),
|
||||
|
||||
ast::expr_addr_of(*) | ast::expr_call(*) |
|
||||
ast::expr_swap(*) | ast::expr_assign(*) |
|
||||
ast::expr_assign_op(*) | ast::expr_fn_block(*) |
|
||||
ast::expr_assert(*) | ast::expr_ret(*) |
|
||||
ast::expr_loop_body(*) | ast::expr_do_body(*) |
|
||||
ast::expr_unary(*) | ast::expr_method_call(*) |
|
||||
ast::expr_copy(*) | ast::expr_cast(*) |
|
||||
ast::expr_addr_of(*) | ast::expr_call(*) | ast::expr_swap(*) |
|
||||
ast::expr_assign(*) | ast::expr_assign_op(*) |
|
||||
ast::expr_fn_block(*) | ast::expr_ret(*) | ast::expr_loop_body(*) |
|
||||
ast::expr_do_body(*) | ast::expr_unary(*) |
|
||||
ast::expr_method_call(*) | ast::expr_copy(*) | ast::expr_cast(*) |
|
||||
ast::expr_vstore(*) | ast::expr_vec(*) | ast::expr_tup(*) |
|
||||
ast::expr_if(*) | ast::expr_log(*) |
|
||||
ast::expr_binary(*) | ast::expr_while(*) |
|
||||
ast::expr_block(*) | ast::expr_loop(*) | ast::expr_match(*) |
|
||||
ast::expr_lit(*) | ast::expr_break(*) | ast::expr_mac(*) |
|
||||
ast::expr_again(*) | ast::expr_struct(*) | ast::expr_repeat(*) => {
|
||||
ast::expr_if(*) | ast::expr_log(*) | ast::expr_binary(*) |
|
||||
ast::expr_while(*) | ast::expr_block(*) | ast::expr_loop(*) |
|
||||
ast::expr_match(*) | ast::expr_lit(*) | ast::expr_break(*) |
|
||||
ast::expr_mac(*) | ast::expr_again(*) | ast::expr_struct(*) |
|
||||
ast::expr_repeat(*) => {
|
||||
return self.cat_rvalue(expr, expr_ty);
|
||||
}
|
||||
}
|
||||
|
@ -571,10 +571,6 @@ fn use_expr(&self,
|
||||
self.use_expr(b_expr, Read, visitor);
|
||||
}
|
||||
|
||||
expr_assert(cond_expr) => {
|
||||
self.consume_expr(cond_expr, visitor);
|
||||
}
|
||||
|
||||
expr_while(cond_expr, ref blk) => {
|
||||
self.consume_expr(cond_expr, visitor);
|
||||
self.consume_block(blk, visitor);
|
||||
|
@ -322,25 +322,6 @@ pub fn trans_ret(bcx: block, e: Option<@ast::expr>) -> block {
|
||||
return bcx;
|
||||
}
|
||||
|
||||
pub fn trans_check_expr(bcx: block,
|
||||
chk_expr: @ast::expr,
|
||||
pred_expr: @ast::expr,
|
||||
s: &str)
|
||||
-> block {
|
||||
let _icx = bcx.insn_ctxt("trans_check_expr");
|
||||
let expr_str = @(fmt!("%s %s failed",
|
||||
s, expr_to_str(pred_expr, bcx.ccx().sess.intr())));
|
||||
let Result {bcx, val} = {
|
||||
do with_scope_result(bcx, chk_expr.info(), ~"check") |bcx| {
|
||||
expr::trans_to_datum(bcx, pred_expr).to_result()
|
||||
}
|
||||
};
|
||||
let val = bool_to_i1(bcx, val);
|
||||
do with_cond(bcx, Not(bcx, val)) |bcx| {
|
||||
trans_fail(bcx, Some(pred_expr.span), expr_str)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn trans_fail_expr(bcx: block,
|
||||
sp_opt: Option<span>,
|
||||
fail_expr: Option<@ast::expr>)
|
||||
|
@ -510,9 +510,6 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block {
|
||||
ast::expr_log(_, lvl, a) => {
|
||||
return controlflow::trans_log(expr, lvl, bcx, a);
|
||||
}
|
||||
ast::expr_assert(a) => {
|
||||
return controlflow::trans_check_expr(bcx, expr, a, ~"Assertion");
|
||||
}
|
||||
ast::expr_while(cond, ref body) => {
|
||||
return controlflow::trans_while(bcx, cond, body);
|
||||
}
|
||||
|
@ -349,11 +349,10 @@ pub fn mark_for_expr(cx: Context, e: @expr) {
|
||||
mark_for_method_call(cx, e.id, e.callee_id);
|
||||
}
|
||||
expr_paren(e) => mark_for_expr(cx, e),
|
||||
expr_match(*) | expr_block(_) | expr_if(*) |
|
||||
expr_while(*) | expr_break(_) | expr_again(_) |
|
||||
expr_unary(_, _) | expr_lit(_) | expr_assert(_) |
|
||||
expr_mac(_) | expr_addr_of(_, _) |
|
||||
expr_ret(_) | expr_loop(_, _) |
|
||||
|
||||
expr_match(*) | expr_block(_) | expr_if(*) | expr_while(*) |
|
||||
expr_break(_) | expr_again(_) | expr_unary(_, _) | expr_lit(_) |
|
||||
expr_mac(_) | expr_addr_of(_, _) | expr_ret(_) | expr_loop(_, _) |
|
||||
expr_loop_body(_) | expr_do_body(_) => ()
|
||||
}
|
||||
}
|
||||
|
@ -3114,7 +3114,6 @@ pub fn expr_kind(tcx: ctxt,
|
||||
ast::expr_again(*) |
|
||||
ast::expr_ret(*) |
|
||||
ast::expr_log(*) |
|
||||
ast::expr_assert(*) |
|
||||
ast::expr_while(*) |
|
||||
ast::expr_loop(*) |
|
||||
ast::expr_assign(*) |
|
||||
|
@ -2309,10 +2309,6 @@ fn check_loop_body(fcx: @mut FnCtxt,
|
||||
check_expr(fcx, e);
|
||||
fcx.write_nil(id);
|
||||
}
|
||||
ast::expr_assert(e) => {
|
||||
bot = check_expr_has_type(fcx, e, ty::mk_bool(tcx));
|
||||
fcx.write_nil(id);
|
||||
}
|
||||
ast::expr_copy(a) => {
|
||||
bot = check_expr_with_opt_hint(fcx, a, expected);
|
||||
fcx.write_ty(id, fcx.expr_ty(a));
|
||||
|
@ -692,7 +692,6 @@ fn guarantor(rcx: @mut Rcx, expr: @ast::expr) -> Option<ty::Region> {
|
||||
ast::expr_again(*) |
|
||||
ast::expr_ret(*) |
|
||||
ast::expr_log(*) |
|
||||
ast::expr_assert(*) |
|
||||
ast::expr_while(*) |
|
||||
ast::expr_loop(*) |
|
||||
ast::expr_assign(*) |
|
||||
|
@ -599,9 +599,6 @@ pub enum expr_ {
|
||||
expr_ret(Option<@expr>),
|
||||
expr_log(log_level, @expr, @expr),
|
||||
|
||||
/* just an assert */
|
||||
expr_assert(@expr),
|
||||
|
||||
expr_mac(mac),
|
||||
|
||||
// A struct literal expression.
|
||||
|
@ -561,7 +561,6 @@ fn fold_field_(field: field, fld: @ast_fold) -> field {
|
||||
fld.fold_expr(e)
|
||||
)
|
||||
}
|
||||
expr_assert(e) => expr_assert(fld.fold_expr(e)),
|
||||
expr_mac(ref mac) => expr_mac(fold_mac((*mac))),
|
||||
expr_struct(path, ref fields, maybe_expr) => {
|
||||
expr_struct(
|
||||
|
@ -51,6 +51,7 @@ pub enum ObsoleteSyntax {
|
||||
ObsoleteTraitImplVisibility,
|
||||
ObsoleteRecordType,
|
||||
ObsoleteRecordPattern,
|
||||
ObsoleteAssertion,
|
||||
}
|
||||
|
||||
impl to_bytes::IterBytes for ObsoleteSyntax {
|
||||
@ -155,6 +156,10 @@ fn obsolete(&self, sp: span, kind: ObsoleteSyntax) {
|
||||
"structural record pattern",
|
||||
"use a structure instead"
|
||||
),
|
||||
ObsoleteAssertion => (
|
||||
"assertion",
|
||||
"use `fail_unless!()` instead"
|
||||
),
|
||||
};
|
||||
|
||||
self.report(sp, kind, kind_str, desc);
|
||||
|
@ -21,7 +21,7 @@
|
||||
use ast::{crate, crate_cfg, decl, decl_item};
|
||||
use ast::{decl_local, default_blk, deref, div, enum_def, enum_variant_kind};
|
||||
use ast::{expl, expr, expr_, expr_addr_of, expr_match, expr_again};
|
||||
use ast::{expr_assert, expr_assign, expr_assign_op, expr_binary, expr_block};
|
||||
use ast::{expr_assign, expr_assign_op, expr_binary, expr_block};
|
||||
use ast::{expr_break, expr_call, expr_cast, expr_copy, expr_do_body};
|
||||
use ast::{expr_field, expr_fn_block, expr_if, expr_index};
|
||||
use ast::{expr_lit, expr_log, expr_loop, expr_loop_body, expr_mac};
|
||||
@ -76,6 +76,7 @@
|
||||
use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer};
|
||||
use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility};
|
||||
use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern};
|
||||
use parse::obsolete::{ObsoleteAssertion};
|
||||
use parse::prec::{as_prec, token_to_binop};
|
||||
use parse::token::{can_begin_expr, is_ident, is_ident_or_path};
|
||||
use parse::token::{is_plain_ident, INTERPOLATED, special_idents};
|
||||
@ -1208,8 +1209,8 @@ fn parse_bottom_expr(&self) -> @expr {
|
||||
self.expect(&token::RPAREN);
|
||||
} else if self.eat_keyword(&~"assert") {
|
||||
let e = self.parse_expr();
|
||||
ex = expr_assert(e);
|
||||
hi = e.span.hi;
|
||||
ex = expr_copy(e); // whatever
|
||||
self.obsolete(*self.last_span, ObsoleteAssertion);
|
||||
} else if self.eat_keyword(&~"return") {
|
||||
if can_begin_expr(&*self.token) {
|
||||
let e = self.parse_expr();
|
||||
|
@ -1427,10 +1427,6 @@ fn print_field(s: @ps, field: ast::field) {
|
||||
}
|
||||
}
|
||||
}
|
||||
ast::expr_assert(expr) => {
|
||||
word_nbsp(s, ~"assert");
|
||||
print_expr(s, expr);
|
||||
}
|
||||
ast::expr_mac(ref m) => print_mac(s, (*m)),
|
||||
ast::expr_paren(e) => {
|
||||
popen(s);
|
||||
|
@ -496,8 +496,7 @@ pub fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
|
||||
(v.visit_expr)(b, e, v);
|
||||
}
|
||||
expr_addr_of(_, x) | expr_unary(_, x) |
|
||||
expr_loop_body(x) | expr_do_body(x) |
|
||||
expr_assert(x) => (v.visit_expr)(x, e, v),
|
||||
expr_loop_body(x) | expr_do_body(x) => (v.visit_expr)(x, e, v),
|
||||
expr_lit(_) => (),
|
||||
expr_cast(x, t) => {
|
||||
(v.visit_expr)(x, e, v);
|
||||
|
Loading…
Reference in New Issue
Block a user