Skip to content

Commit 9a17ef9

Browse files
committed
librustc: Stop parsing assert.
1 parent d7e74b5 commit 9a17ef9

File tree

16 files changed

+38
-77
lines changed

16 files changed

+38
-77
lines changed

src/libfuzzer/fuzzer.rc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ pub pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
109109
| ast::expr_match(*) | ast::expr_while(*) => { false }
110110

111111
// https://github.com/mozilla/rust/issues/929
112-
ast::expr_cast(*) | ast::expr_assert(*) |
113-
ast::expr_binary(*) | ast::expr_assign(*) |
112+
ast::expr_cast(*) | ast::expr_binary(*) | ast::expr_assign(*) |
114113
ast::expr_assign_op(*) => { false }
115114

116115
ast::expr_ret(option::None) => { false }

src/librustc/middle/liveness.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -617,11 +617,11 @@ fn visit_expr(expr: @expr, &&self: @mut IrMaps, vt: vt<@mut IrMaps>) {
617617
// otherwise, live nodes are not required:
618618
expr_index(*) | expr_field(*) | expr_vstore(*) | expr_vec(*) |
619619
expr_call(*) | expr_method_call(*) | expr_tup(*) | expr_log(*) |
620-
expr_binary(*) | expr_assert(*) | expr_addr_of(*) | expr_copy(*) |
621-
expr_loop_body(*) | expr_do_body(*) | expr_cast(*) | expr_unary(*) |
622-
expr_break(_) | expr_again(_) | expr_lit(_) | expr_ret(*) |
623-
expr_block(*) | expr_assign(*) | expr_swap(*) | expr_assign_op(*) |
624-
expr_mac(*) | expr_struct(*) | expr_repeat(*) | expr_paren(*) => {
620+
expr_binary(*) | expr_addr_of(*) | expr_copy(*) | expr_loop_body(*) |
621+
expr_do_body(*) | expr_cast(*) | expr_unary(*) | expr_break(_) |
622+
expr_again(_) | expr_lit(_) | expr_ret(*) | expr_block(*) |
623+
expr_assign(*) | expr_swap(*) | expr_assign_op(*) | expr_mac(*) |
624+
expr_struct(*) | expr_repeat(*) | expr_paren(*) => {
625625
visit::visit_expr(expr, self, vt);
626626
}
627627
}
@@ -1332,7 +1332,6 @@ pub impl Liveness {
13321332
self.propagate_through_exprs(~[l, r], succ)
13331333
}
13341334

1335-
expr_assert(e) |
13361335
expr_addr_of(_, e) |
13371336
expr_copy(e) |
13381337
expr_loop_body(e) |
@@ -1493,8 +1492,9 @@ pub impl Liveness {
14931492
// repeat until fixed point is reached:
14941493
while self.merge_from_succ(ln, body_ln, first_merge) {
14951494
first_merge = false;
1496-
fail_unless!(cond_ln == self.propagate_through_opt_expr(cond, ln));
1497-
assert body_ln == self.with_loop_nodes(expr.id, succ, ln,
1495+
fail_unless!(cond_ln == self.propagate_through_opt_expr(cond,
1496+
ln));
1497+
fail_unless!(body_ln == self.with_loop_nodes(expr.id, succ, ln,
14981498
|| {
14991499
self.propagate_through_block(body, cond_ln)
15001500
}));
@@ -1611,11 +1611,11 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
16111611
expr_call(*) | expr_method_call(*) | expr_if(*) | expr_match(*) |
16121612
expr_while(*) | expr_loop(*) | expr_index(*) | expr_field(*) |
16131613
expr_vstore(*) | expr_vec(*) | expr_tup(*) | expr_log(*) |
1614-
expr_binary(*) | expr_assert(*) | expr_copy(*) | expr_loop_body(*) |
1615-
expr_do_body(*) | expr_cast(*) | expr_unary(*) | expr_ret(*) |
1616-
expr_break(*) | expr_again(*) | expr_lit(_) | expr_block(*) |
1617-
expr_swap(*) | expr_mac(*) | expr_addr_of(*) | expr_struct(*) |
1618-
expr_repeat(*) | expr_paren(*) => {
1614+
expr_binary(*) | expr_copy(*) | expr_loop_body(*) | expr_do_body(*) |
1615+
expr_cast(*) | expr_unary(*) | expr_ret(*) | expr_break(*) |
1616+
expr_again(*) | expr_lit(_) | expr_block(*) | expr_swap(*) |
1617+
expr_mac(*) | expr_addr_of(*) | expr_struct(*) | expr_repeat(*) |
1618+
expr_paren(*) => {
16191619
visit::visit_expr(expr, self, vt);
16201620
}
16211621
}

src/librustc/middle/mem_categorization.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -437,19 +437,17 @@ pub impl mem_categorization_ctxt {
437437

438438
ast::expr_paren(e) => self.cat_expr_unadjusted(e),
439439

440-
ast::expr_addr_of(*) | ast::expr_call(*) |
441-
ast::expr_swap(*) | ast::expr_assign(*) |
442-
ast::expr_assign_op(*) | ast::expr_fn_block(*) |
443-
ast::expr_assert(*) | ast::expr_ret(*) |
444-
ast::expr_loop_body(*) | ast::expr_do_body(*) |
445-
ast::expr_unary(*) | ast::expr_method_call(*) |
446-
ast::expr_copy(*) | ast::expr_cast(*) |
440+
ast::expr_addr_of(*) | ast::expr_call(*) | ast::expr_swap(*) |
441+
ast::expr_assign(*) | ast::expr_assign_op(*) |
442+
ast::expr_fn_block(*) | ast::expr_ret(*) | ast::expr_loop_body(*) |
443+
ast::expr_do_body(*) | ast::expr_unary(*) |
444+
ast::expr_method_call(*) | ast::expr_copy(*) | ast::expr_cast(*) |
447445
ast::expr_vstore(*) | ast::expr_vec(*) | ast::expr_tup(*) |
448-
ast::expr_if(*) | ast::expr_log(*) |
449-
ast::expr_binary(*) | ast::expr_while(*) |
450-
ast::expr_block(*) | ast::expr_loop(*) | ast::expr_match(*) |
451-
ast::expr_lit(*) | ast::expr_break(*) | ast::expr_mac(*) |
452-
ast::expr_again(*) | ast::expr_struct(*) | ast::expr_repeat(*) => {
446+
ast::expr_if(*) | ast::expr_log(*) | ast::expr_binary(*) |
447+
ast::expr_while(*) | ast::expr_block(*) | ast::expr_loop(*) |
448+
ast::expr_match(*) | ast::expr_lit(*) | ast::expr_break(*) |
449+
ast::expr_mac(*) | ast::expr_again(*) | ast::expr_struct(*) |
450+
ast::expr_repeat(*) => {
453451
return self.cat_rvalue(expr, expr_ty);
454452
}
455453
}

src/librustc/middle/moves.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,6 @@ pub impl VisitContext {
571571
self.use_expr(b_expr, Read, visitor);
572572
}
573573

574-
expr_assert(cond_expr) => {
575-
self.consume_expr(cond_expr, visitor);
576-
}
577-
578574
expr_while(cond_expr, ref blk) => {
579575
self.consume_expr(cond_expr, visitor);
580576
self.consume_block(blk, visitor);

src/librustc/middle/trans/controlflow.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -322,25 +322,6 @@ pub fn trans_ret(bcx: block, e: Option<@ast::expr>) -> block {
322322
return bcx;
323323
}
324324
325-
pub fn trans_check_expr(bcx: block,
326-
chk_expr: @ast::expr,
327-
pred_expr: @ast::expr,
328-
s: &str)
329-
-> block {
330-
let _icx = bcx.insn_ctxt("trans_check_expr");
331-
let expr_str = @(fmt!("%s %s failed",
332-
s, expr_to_str(pred_expr, bcx.ccx().sess.intr())));
333-
let Result {bcx, val} = {
334-
do with_scope_result(bcx, chk_expr.info(), ~"check") |bcx| {
335-
expr::trans_to_datum(bcx, pred_expr).to_result()
336-
}
337-
};
338-
let val = bool_to_i1(bcx, val);
339-
do with_cond(bcx, Not(bcx, val)) |bcx| {
340-
trans_fail(bcx, Some(pred_expr.span), expr_str)
341-
}
342-
}
343-
344325
pub fn trans_fail_expr(bcx: block,
345326
sp_opt: Option<span>,
346327
fail_expr: Option<@ast::expr>)

src/librustc/middle/trans/expr.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,6 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block {
510510
ast::expr_log(_, lvl, a) => {
511511
return controlflow::trans_log(expr, lvl, bcx, a);
512512
}
513-
ast::expr_assert(a) => {
514-
return controlflow::trans_check_expr(bcx, expr, a, ~"Assertion");
515-
}
516513
ast::expr_while(cond, ref body) => {
517514
return controlflow::trans_while(bcx, cond, body);
518515
}

src/librustc/middle/trans/type_use.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,10 @@ pub fn mark_for_expr(cx: Context, e: @expr) {
349349
mark_for_method_call(cx, e.id, e.callee_id);
350350
}
351351
expr_paren(e) => mark_for_expr(cx, e),
352-
expr_match(*) | expr_block(_) | expr_if(*) |
353-
expr_while(*) | expr_break(_) | expr_again(_) |
354-
expr_unary(_, _) | expr_lit(_) | expr_assert(_) |
355-
expr_mac(_) | expr_addr_of(_, _) |
356-
expr_ret(_) | expr_loop(_, _) |
352+
353+
expr_match(*) | expr_block(_) | expr_if(*) | expr_while(*) |
354+
expr_break(_) | expr_again(_) | expr_unary(_, _) | expr_lit(_) |
355+
expr_mac(_) | expr_addr_of(_, _) | expr_ret(_) | expr_loop(_, _) |
357356
expr_loop_body(_) | expr_do_body(_) => ()
358357
}
359358
}

src/librustc/middle/ty.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3114,7 +3114,6 @@ pub fn expr_kind(tcx: ctxt,
31143114
ast::expr_again(*) |
31153115
ast::expr_ret(*) |
31163116
ast::expr_log(*) |
3117-
ast::expr_assert(*) |
31183117
ast::expr_while(*) |
31193118
ast::expr_loop(*) |
31203119
ast::expr_assign(*) |

src/librustc/middle/typeck/check/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,10 +2309,6 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
23092309
check_expr(fcx, e);
23102310
fcx.write_nil(id);
23112311
}
2312-
ast::expr_assert(e) => {
2313-
bot = check_expr_has_type(fcx, e, ty::mk_bool(tcx));
2314-
fcx.write_nil(id);
2315-
}
23162312
ast::expr_copy(a) => {
23172313
bot = check_expr_with_opt_hint(fcx, a, expected);
23182314
fcx.write_ty(id, fcx.expr_ty(a));

src/librustc/middle/typeck/check/regionck.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,6 @@ pub mod guarantor {
692692
ast::expr_again(*) |
693693
ast::expr_ret(*) |
694694
ast::expr_log(*) |
695-
ast::expr_assert(*) |
696695
ast::expr_while(*) |
697696
ast::expr_loop(*) |
698697
ast::expr_assign(*) |

src/libsyntax/ast.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,6 @@ pub enum expr_ {
599599
expr_ret(Option<@expr>),
600600
expr_log(log_level, @expr, @expr),
601601
602-
/* just an assert */
603-
expr_assert(@expr),
604-
605602
expr_mac(mac),
606603
607604
// A struct literal expression.

src/libsyntax/fold.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ {
561561
fld.fold_expr(e)
562562
)
563563
}
564-
expr_assert(e) => expr_assert(fld.fold_expr(e)),
565564
expr_mac(ref mac) => expr_mac(fold_mac((*mac))),
566565
expr_struct(path, ref fields, maybe_expr) => {
567566
expr_struct(

src/libsyntax/parse/obsolete.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub enum ObsoleteSyntax {
5151
ObsoleteTraitImplVisibility,
5252
ObsoleteRecordType,
5353
ObsoleteRecordPattern,
54+
ObsoleteAssertion,
5455
}
5556

5657
impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -155,6 +156,10 @@ pub impl Parser {
155156
"structural record pattern",
156157
"use a structure instead"
157158
),
159+
ObsoleteAssertion => (
160+
"assertion",
161+
"use `fail_unless!()` instead"
162+
),
158163
};
159164

160165
self.report(sp, kind, kind_str, desc);

src/libsyntax/parse/parser.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use ast::{blk_check_mode, box, by_copy, by_ref, by_val};
2121
use ast::{crate, crate_cfg, decl, decl_item};
2222
use ast::{decl_local, default_blk, deref, div, enum_def, enum_variant_kind};
2323
use ast::{expl, expr, expr_, expr_addr_of, expr_match, expr_again};
24-
use ast::{expr_assert, expr_assign, expr_assign_op, expr_binary, expr_block};
24+
use ast::{expr_assign, expr_assign_op, expr_binary, expr_block};
2525
use ast::{expr_break, expr_call, expr_cast, expr_copy, expr_do_body};
2626
use ast::{expr_field, expr_fn_block, expr_if, expr_index};
2727
use ast::{expr_lit, expr_log, expr_loop, expr_loop_body, expr_mac};
@@ -76,6 +76,7 @@ use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax};
7676
use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer};
7777
use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility};
7878
use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern};
79+
use parse::obsolete::{ObsoleteAssertion};
7980
use parse::prec::{as_prec, token_to_binop};
8081
use parse::token::{can_begin_expr, is_ident, is_ident_or_path};
8182
use parse::token::{is_plain_ident, INTERPOLATED, special_idents};
@@ -1208,8 +1209,8 @@ pub impl Parser {
12081209
self.expect(&token::RPAREN);
12091210
} else if self.eat_keyword(&~"assert") {
12101211
let e = self.parse_expr();
1211-
ex = expr_assert(e);
1212-
hi = e.span.hi;
1212+
ex = expr_copy(e); // whatever
1213+
self.obsolete(*self.last_span, ObsoleteAssertion);
12131214
} else if self.eat_keyword(&~"return") {
12141215
if can_begin_expr(&*self.token) {
12151216
let e = self.parse_expr();

src/libsyntax/print/pprust.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,10 +1427,6 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
14271427
}
14281428
}
14291429
}
1430-
ast::expr_assert(expr) => {
1431-
word_nbsp(s, ~"assert");
1432-
print_expr(s, expr);
1433-
}
14341430
ast::expr_mac(ref m) => print_mac(s, (*m)),
14351431
ast::expr_paren(e) => {
14361432
popen(s);

src/libsyntax/visit.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,7 @@ pub fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
496496
(v.visit_expr)(b, e, v);
497497
}
498498
expr_addr_of(_, x) | expr_unary(_, x) |
499-
expr_loop_body(x) | expr_do_body(x) |
500-
expr_assert(x) => (v.visit_expr)(x, e, v),
499+
expr_loop_body(x) | expr_do_body(x) => (v.visit_expr)(x, e, v),
501500
expr_lit(_) => (),
502501
expr_cast(x, t) => {
503502
(v.visit_expr)(x, e, v);

0 commit comments

Comments
 (0)