diff --git a/src/libfuzzer/fuzzer.rc b/src/libfuzzer/fuzzer.rc index 8257af5760f..19afbc4b2b7 100644 --- a/src/libfuzzer/fuzzer.rc +++ b/src/libfuzzer/fuzzer.rc @@ -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 } diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 473fad5ee25..5d652571ab1 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -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); } } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 18cf02cf66d..00cab7961ca 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -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); } } diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index 826fc54f054..182697b290f 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -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); diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 59c143ebce7..e60223c9eff 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -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, fail_expr: Option<@ast::expr>) diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 7f9ff2a244b..b7942fa66db 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -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); } diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index 8699b4f0139..710bb5eb346 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -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(_) => () } } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 350c1526ce0..082c64ced8e 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -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(*) | diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 65646cfcbb1..6efa62c55cc 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -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)); diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 392182bee3f..818a444a4f3 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -692,7 +692,6 @@ fn guarantor(rcx: @mut Rcx, expr: @ast::expr) -> Option { ast::expr_again(*) | ast::expr_ret(*) | ast::expr_log(*) | - ast::expr_assert(*) | ast::expr_while(*) | ast::expr_loop(*) | ast::expr_assign(*) | diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 0581f5f96b0..a6ccd69dd06 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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. diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index ea18598f75c..b8371c9e8d9 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -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( diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 4e1b34bb299..6f2d2c554aa 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -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); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 0dba2bd45e1..384cf4f0e95 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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(); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index d87238c720e..4a8176abc6f 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -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); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 8b277b22149..6048256b90b 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -496,8 +496,7 @@ pub fn visit_expr(ex: @expr, e: E, v: vt) { (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);