Add optional message to fail.
This commit is contained in:
parent
b5c73605ea
commit
2235fb73ef
10 changed files with 41 additions and 13 deletions
|
|
@ -5628,8 +5628,17 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output)
|
|||
ret trans_expr(cx, expanded);
|
||||
}
|
||||
|
||||
case (ast::expr_fail(_)) {
|
||||
ret trans_fail(cx, some(e.span), "explicit failure");
|
||||
case (ast::expr_fail(_, ?str)) {
|
||||
auto failmsg;
|
||||
alt (str) {
|
||||
case (some(?msg)) {
|
||||
failmsg = msg;
|
||||
}
|
||||
case (_) {
|
||||
failmsg = "explicit failure";
|
||||
}
|
||||
}
|
||||
ret trans_fail(cx, some(e.span), failmsg);
|
||||
}
|
||||
|
||||
case (ast::expr_log(?lvl, ?a, _)) {
|
||||
|
|
|
|||
|
|
@ -459,7 +459,7 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) -> () {
|
|||
find_pre_post_expr(fcx, operator);
|
||||
copy_pre_post(fcx.ccx, a, operator);
|
||||
}
|
||||
case (expr_fail(?a)) {
|
||||
case (expr_fail(?a, _)) {
|
||||
set_pre_and_post(fcx.ccx, a,
|
||||
/* if execution continues after fail,
|
||||
then everything is true! */
|
||||
|
|
|
|||
|
|
@ -508,7 +508,7 @@ fn find_pre_post_state_expr(&fn_ctxt fcx, &prestate pres, @expr e) -> bool {
|
|||
expr_poststate(fcx.ccx, operand)) || changed;
|
||||
ret changed;
|
||||
}
|
||||
case (expr_fail(?a)) {
|
||||
case (expr_fail(?a, _)) {
|
||||
changed = extend_prestate_ann(fcx.ccx, a, pres) || changed;
|
||||
/* if execution continues after fail, then everything is true! woo! */
|
||||
changed = set_poststate_ann(fcx.ccx, a,
|
||||
|
|
|
|||
|
|
@ -1657,7 +1657,7 @@ fn expr_ann(&@ast::expr e) -> ast::ann {
|
|||
case (ast::expr_index(_,_,?a)) { ret a; }
|
||||
case (ast::expr_path(_,?a)) { ret a; }
|
||||
case (ast::expr_ext(_,_,_,_,?a)) { ret a; }
|
||||
case (ast::expr_fail(?a)) { ret a; }
|
||||
case (ast::expr_fail(?a,_)) { ret a; }
|
||||
case (ast::expr_ret(_,?a)) { ret a; }
|
||||
case (ast::expr_put(_,?a)) { ret a; }
|
||||
case (ast::expr_be(_,?a)) { ret a; }
|
||||
|
|
|
|||
|
|
@ -1276,7 +1276,7 @@ mod pushdown {
|
|||
write::ty_only_fixup(fcx, ann.id, t);
|
||||
}
|
||||
/* FIXME: should this check the type annotations? */
|
||||
case (ast::expr_fail(_)) { /* no-op */ }
|
||||
case (ast::expr_fail(_,_)) { /* no-op */ }
|
||||
case (ast::expr_log(_,_,_)) { /* no-op */ }
|
||||
case (ast::expr_break(_)) { /* no-op */ }
|
||||
case (ast::expr_cont(_)) { /* no-op */ }
|
||||
|
|
@ -1972,7 +1972,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
write::ty_only_fixup(fcx, a.id, t);
|
||||
}
|
||||
|
||||
case (ast::expr_fail(?a)) {
|
||||
case (ast::expr_fail(?a, _)) {
|
||||
write::bot_ty(fcx.ccx.tcx, a.id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ fn walk_expr(&ast_visitor v, @ast::expr e) {
|
|||
// Only walk expansion, not args/body.
|
||||
walk_expr(v, expansion);
|
||||
}
|
||||
case (ast::expr_fail(_)) { }
|
||||
case (ast::expr_fail(_, _)) { }
|
||||
case (ast::expr_break(_)) { }
|
||||
case (ast::expr_cont(_)) { }
|
||||
case (ast::expr_ret(?eo, _)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue