Skip to content

Commit 52a677c

Browse files
Paul Woolcockmarijnh
authored andcommitted
---
yaml --- r: 7918 b: refs/heads/snap-stage3 c: 6ba3d24 h: refs/heads/master v: v3
1 parent d0ece8d commit 52a677c

File tree

16 files changed

+6
-83
lines changed

16 files changed

+6
-83
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: a02493b96919bae8c27a2508a08709dbabdfc744
4+
refs/heads/snap-stage3: 6ba3d2435556ae4ea72eeb6095e95b5c14a3c1f7
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/doc/tutorial.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -473,13 +473,6 @@ The comparison operators are the traditional `==`, `!=`, `<`, `>`,
473473
`<=`, and `>=`. Short-circuiting (lazy) boolean operators are written
474474
`&&` (and) and `||` (or).
475475

476-
Rust has a ternary conditional operator `?:`, as in:
477-
478-
~~~~
479-
let badness = 12;
480-
let message = badness < 10 ? "error" : "FATAL ERROR";
481-
~~~~
482-
483476
For type casting, Rust uses the binary `as` operator, which has a
484477
precedence between the bitwise combination operators (`&`, `|`, `^`)
485478
and the comparison operators. It takes an expression on the left side,

branches/snap-stage3/src/comp/middle/kind.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
188188
none {}
189189
}
190190
}
191-
expr_ternary(_, a, b) { maybe_copy(cx, a); maybe_copy(cx, b); }
192191
expr_fn(_, _, _, cap_clause) {
193192
check_fn_cap_clause(cx, e.id, *cap_clause);
194193
}

branches/snap-stage3/src/comp/middle/last_use.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
8888
v.visit_expr(coll, cx, v);
8989
visit_block(loop, cx) {|| visit::visit_block(blk, cx, v);}
9090
}
91-
expr_ternary(_, _, _) {
92-
v.visit_expr(ast_util::ternary_to_if(ex), cx, v);
93-
}
9491
expr_alt(input, arms) {
9592
v.visit_expr(input, cx, v);
9693
let before = cx.current, sets = [];

branches/snap-stage3/src/comp/middle/trans/base.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3478,9 +3478,6 @@ fn trans_expr(bcx: @block_ctxt, e: @ast::expr, dest: dest) -> @block_ctxt {
34783478
ast::expr_if(cond, thn, els) | ast::expr_if_check(cond, thn, els) {
34793479
ret trans_if(bcx, cond, thn, els, dest);
34803480
}
3481-
ast::expr_ternary(_, _, _) {
3482-
ret trans_expr(bcx, ast_util::ternary_to_if(e), dest);
3483-
}
34843481
ast::expr_alt(expr, arms) {
34853482
// tcx.sess.span_note(e.span, "about to call trans_alt");
34863483
ret alt::trans_alt(bcx, expr, arms, dest);

branches/snap-stage3/src/comp/middle/tstate/pre_post_conditions.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
415415
expr_if(antec, conseq, maybe_alt) {
416416
join_then_else(fcx, antec, conseq, maybe_alt, e.id, plain_if);
417417
}
418-
expr_ternary(_, _, _) { find_pre_post_expr(fcx, ternary_to_if(e)); }
419418
expr_binary(bop, l, r) {
420419
if lazy_binop(bop) {
421420
find_pre_post_expr(fcx, l);

branches/snap-stage3/src/comp/middle/tstate/states.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,6 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
466466
ret join_then_else(fcx, antec, conseq, maybe_alt, e.id, plain_if,
467467
pres);
468468
}
469-
expr_ternary(_, _, _) {
470-
ret find_pre_post_state_expr(fcx, pres, ternary_to_if(e));
471-
}
472469
expr_binary(bop, l, r) {
473470
if lazy_binop(bop) {
474471
let changed = find_pre_post_state_expr(fcx, pres, l);

branches/snap-stage3/src/comp/middle/typeck.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,9 +1921,6 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
19211921
check_pred_expr(fcx, cond) |
19221922
check_then_else(fcx, thn, elsopt, id, expr.span);
19231923
}
1924-
ast::expr_ternary(_, _, _) {
1925-
bot = check_expr(fcx, ast_util::ternary_to_if(expr));
1926-
}
19271924
ast::expr_assert(e) {
19281925
bot = check_expr_with(fcx, e, ty::mk_bool(tcx));
19291926
write_nil(tcx, id);

branches/snap-stage3/src/comp/syntax/ast.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ enum expr_ {
213213
expr_lit(@lit),
214214
expr_cast(@expr, @ty),
215215
expr_if(@expr, blk, option::t<@expr>),
216-
expr_ternary(@expr, @expr, @expr),
217216
expr_while(@expr, blk),
218217
expr_for(@local, @expr, blk),
219218
expr_do_while(blk, @expr),

branches/snap-stage3/src/comp/syntax/ast_util.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -205,23 +205,6 @@ fn default_block(stmts1: [@stmt], expr1: option::t<@expr>, id1: node_id) ->
205205
{view_items: [], stmts: stmts1, expr: expr1, id: id1, rules: default_blk}
206206
}
207207

208-
// This is a convenience function to transfor ternary expressions to if
209-
// expressions so that they can be treated the same
210-
fn ternary_to_if(e: @expr) -> @expr {
211-
alt e.node {
212-
expr_ternary(cond, then, els) {
213-
let then_blk = block_from_expr(then);
214-
let els_blk = block_from_expr(els);
215-
let els_expr =
216-
@{id: els.id, node: expr_block(els_blk), span: els.span};
217-
ret @{id: e.id,
218-
node: expr_if(cond, then_blk, option::some(els_expr)),
219-
span: e.span};
220-
}
221-
_ { fail; }
222-
}
223-
}
224-
225208
// FIXME this doesn't handle big integer/float literals correctly (nor does
226209
// the rest of our literal handling)
227210
enum const_val {

branches/snap-stage3/src/comp/syntax/fold.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,6 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
352352
expr_if(fld.fold_expr(cond), fld.fold_block(tr),
353353
option::map(fl, fld.fold_expr))
354354
}
355-
expr_ternary(cond, tr, fl) {
356-
expr_ternary(fld.fold_expr(cond), fld.fold_expr(tr),
357-
fld.fold_expr(fl))
358-
}
359355
expr_while(cond, body) {
360356
expr_while(fld.fold_expr(cond), fld.fold_block(body))
361357
}

branches/snap-stage3/src/comp/syntax/parse/lexer.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,6 @@ fn next_token_inner(rdr: reader) -> token::token {
328328

329329

330330
// One-byte tokens.
331-
'?' {
332-
rdr.bump();
333-
ret token::QUES;
334-
}
335331
';' { rdr.bump(); ret token::SEMI; }
336332
',' { rdr.bump(); ret token::COMMA; }
337333
'.' {

branches/snap-stage3/src/comp/syntax/parse/parser.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,18 +1097,6 @@ fn parse_prefix_expr(p: parser) -> pexpr {
10971097
ret mk_pexpr(p, lo, hi, ex);
10981098
}
10991099

1100-
fn parse_ternary(p: parser) -> @ast::expr {
1101-
let cond_expr = parse_binops(p);
1102-
if p.token == token::QUES {
1103-
p.bump();
1104-
let then_expr = parse_expr(p);
1105-
expect(p, token::COLON);
1106-
let else_expr = parse_expr(p);
1107-
ret mk_expr(p, cond_expr.span.lo, else_expr.span.hi,
1108-
ast::expr_ternary(cond_expr, then_expr, else_expr));
1109-
} else { ret cond_expr; }
1110-
}
1111-
11121100
type op_spec = {tok: token::token, op: ast::binop, prec: int};
11131101

11141102

@@ -1143,7 +1131,6 @@ fn parse_binops(p: parser) -> @ast::expr {
11431131
const unop_prec: int = 100;
11441132

11451133
const as_prec: int = 5;
1146-
const ternary_prec: int = 0;
11471134

11481135
fn parse_more_binops(p: parser, plhs: pexpr, min_prec: int) ->
11491136
@ast::expr {
@@ -1174,7 +1161,7 @@ fn parse_more_binops(p: parser, plhs: pexpr, min_prec: int) ->
11741161

11751162
fn parse_assign_expr(p: parser) -> @ast::expr {
11761163
let lo = p.span.lo;
1177-
let lhs = parse_ternary(p);
1164+
let lhs = parse_binops(p);
11781165
alt p.token {
11791166
token::EQ {
11801167
p.bump();

branches/snap-stage3/src/comp/syntax/parse/token.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ enum token {
4343
SEMI,
4444
COLON,
4545
MOD_SEP,
46-
QUES,
4746
RARROW,
4847
LARROW,
4948
DARROW,
@@ -114,7 +113,6 @@ fn to_str(r: reader, t: token) -> str {
114113
SEMI { ret ";"; }
115114
COLON { ret ":"; }
116115
MOD_SEP { ret "::"; }
117-
QUES { ret "?"; }
118116
RARROW { ret "->"; }
119117
LARROW { ret "<-"; }
120118
DARROW { ret "<->"; }

branches/snap-stage3/src/comp/syntax/print/pprust.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -855,15 +855,6 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
855855
ast::expr_if_check(test, blk, elseopt) {
856856
print_if(s, test, blk, elseopt, true);
857857
}
858-
ast::expr_ternary(test, then, els) {
859-
print_expr(s, test);
860-
space(s.s);
861-
word_space(s, "?");
862-
print_expr(s, then);
863-
space(s.s);
864-
word_space(s, ":");
865-
print_expr(s, els);
866-
}
867858
ast::expr_while(test, blk) {
868859
head(s, "while");
869860
print_maybe_parens_discrim(s, test);
@@ -1044,8 +1035,8 @@ fn print_expr_parens_if_not_bot(s: ps, ex: @ast::expr) {
10441035
let parens = alt ex.node {
10451036
ast::expr_fail(_) | ast::expr_ret(_) |
10461037
ast::expr_binary(_, _, _) | ast::expr_unary(_, _) |
1047-
ast::expr_ternary(_, _, _) | ast::expr_move(_, _) |
1048-
ast::expr_copy(_) | ast::expr_assign(_, _) | ast::expr_be(_) |
1038+
ast::expr_move(_, _) | ast::expr_copy(_) |
1039+
ast::expr_assign(_, _) | ast::expr_be(_) |
10491040
ast::expr_assign_op(_, _, _) | ast::expr_swap(_, _) |
10501041
ast::expr_log(_, _, _) | ast::expr_assert(_) |
10511042
ast::expr_call(_, _, true) |
@@ -1395,7 +1386,6 @@ fn need_parens(expr: @ast::expr, outer_prec: int) -> bool {
13951386
alt expr.node {
13961387
ast::expr_binary(op, _, _) { operator_prec(op) < outer_prec }
13971388
ast::expr_cast(_, _) { parse::parser::as_prec < outer_prec }
1398-
ast::expr_ternary(_, _, _) { parse::parser::ternary_prec < outer_prec }
13991389
// This may be too conservative in some cases
14001390
ast::expr_assign(_, _) { true }
14011391
ast::expr_move(_, _) { true }
@@ -1757,8 +1747,8 @@ fn ends_in_lit_int(ex: @ast::expr) -> bool {
17571747
alt ex.node {
17581748
ast::expr_lit(@{node: ast::lit_int(_, ast::ty_i), _}) { true }
17591749
ast::expr_binary(_, _, sub) | ast::expr_unary(_, sub) |
1760-
ast::expr_ternary(_, _, sub) | ast::expr_move(_, sub) |
1761-
ast::expr_copy(sub) | ast::expr_assign(_, sub) | ast::expr_be(sub) |
1750+
ast::expr_move(_, sub) | ast::expr_copy(sub) |
1751+
ast::expr_assign(_, sub) | ast::expr_be(sub) |
17621752
ast::expr_assign_op(_, _, sub) | ast::expr_swap(_, sub) |
17631753
ast::expr_log(_, _, sub) | ast::expr_assert(sub) |
17641754
ast::expr_check(_, sub) { ends_in_lit_int(sub) }

branches/snap-stage3/src/comp/syntax/visit.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,6 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
312312
v.visit_block(b, e, v);
313313
visit_expr_opt(eo, e, v);
314314
}
315-
expr_ternary(c, t, el) {
316-
v.visit_expr(c, e, v);
317-
v.visit_expr(t, e, v);
318-
v.visit_expr(el, e, v);
319-
}
320315
expr_while(x, b) { v.visit_expr(x, e, v); v.visit_block(b, e, v); }
321316
expr_for(dcl, x, b) {
322317
v.visit_local(dcl, e, v);

0 commit comments

Comments
 (0)