about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--doc/tutorial.md7
-rw-r--r--src/comp/middle/kind.rs1
-rw-r--r--src/comp/middle/last_use.rs3
-rw-r--r--src/comp/middle/trans/base.rs3
-rw-r--r--src/comp/middle/tstate/pre_post_conditions.rs1
-rw-r--r--src/comp/middle/tstate/states.rs3
-rw-r--r--src/comp/middle/typeck.rs3
-rw-r--r--src/comp/syntax/ast.rs1
-rw-r--r--src/comp/syntax/ast_util.rs17
-rw-r--r--src/comp/syntax/fold.rs4
-rw-r--r--src/comp/syntax/parse/lexer.rs4
-rw-r--r--src/comp/syntax/parse/parser.rs15
-rw-r--r--src/comp/syntax/parse/token.rs2
-rw-r--r--src/comp/syntax/print/pprust.rs18
-rw-r--r--src/comp/syntax/visit.rs5
15 files changed, 5 insertions, 82 deletions
diff --git a/doc/tutorial.md b/doc/tutorial.md
index 9a955f8a8b8..1c36bfee610 100644
--- a/doc/tutorial.md
+++ b/doc/tutorial.md
@@ -473,13 +473,6 @@ The comparison operators are the traditional `==`, `!=`, `<`, `>`,
 `<=`, and `>=`. Short-circuiting (lazy) boolean operators are written
 `&&` (and) and `||` (or).
 
-Rust has a ternary conditional operator `?:`, as in:
-
-~~~~
-let badness = 12;
-let message = badness < 10 ? "error" : "FATAL ERROR";
-~~~~
-
 For type casting, Rust uses the binary `as` operator, which has a
 precedence between the bitwise combination operators (`&`, `|`, `^`)
 and the comparison operators. It takes an expression on the left side,
diff --git a/src/comp/middle/kind.rs b/src/comp/middle/kind.rs
index d8dca5c0115..9c3796a7e01 100644
--- a/src/comp/middle/kind.rs
+++ b/src/comp/middle/kind.rs
@@ -188,7 +188,6 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
           none {}
         }
       }
-      expr_ternary(_, a, b) { maybe_copy(cx, a); maybe_copy(cx, b); }
       expr_fn(_, _, _, cap_clause) {
         check_fn_cap_clause(cx, e.id, *cap_clause);
       }
diff --git a/src/comp/middle/last_use.rs b/src/comp/middle/last_use.rs
index ceaff558286..190e88deae6 100644
--- a/src/comp/middle/last_use.rs
+++ b/src/comp/middle/last_use.rs
@@ -88,9 +88,6 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
         v.visit_expr(coll, cx, v);
         visit_block(loop, cx) {|| visit::visit_block(blk, cx, v);}
       }
-      expr_ternary(_, _, _) {
-        v.visit_expr(ast_util::ternary_to_if(ex), cx, v);
-      }
       expr_alt(input, arms) {
         v.visit_expr(input, cx, v);
         let before = cx.current, sets = [];
diff --git a/src/comp/middle/trans/base.rs b/src/comp/middle/trans/base.rs
index 2ac1ca102f5..a0439f10fae 100644
--- a/src/comp/middle/trans/base.rs
+++ b/src/comp/middle/trans/base.rs
@@ -3478,9 +3478,6 @@ fn trans_expr(bcx: @block_ctxt, e: @ast::expr, dest: dest) -> @block_ctxt {
       ast::expr_if(cond, thn, els) | ast::expr_if_check(cond, thn, els) {
         ret trans_if(bcx, cond, thn, els, dest);
       }
-      ast::expr_ternary(_, _, _) {
-        ret trans_expr(bcx, ast_util::ternary_to_if(e), dest);
-      }
       ast::expr_alt(expr, arms) {
           //          tcx.sess.span_note(e.span, "about to call trans_alt");
         ret alt::trans_alt(bcx, expr, arms, dest);
diff --git a/src/comp/middle/tstate/pre_post_conditions.rs b/src/comp/middle/tstate/pre_post_conditions.rs
index 99bb750f3b7..987bbb4d81d 100644
--- a/src/comp/middle/tstate/pre_post_conditions.rs
+++ b/src/comp/middle/tstate/pre_post_conditions.rs
@@ -415,7 +415,6 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
       expr_if(antec, conseq, maybe_alt) {
         join_then_else(fcx, antec, conseq, maybe_alt, e.id, plain_if);
       }
-      expr_ternary(_, _, _) { find_pre_post_expr(fcx, ternary_to_if(e)); }
       expr_binary(bop, l, r) {
         if lazy_binop(bop) {
             find_pre_post_expr(fcx, l);
diff --git a/src/comp/middle/tstate/states.rs b/src/comp/middle/tstate/states.rs
index 2a976d0469f..a125c00d63b 100644
--- a/src/comp/middle/tstate/states.rs
+++ b/src/comp/middle/tstate/states.rs
@@ -466,9 +466,6 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
         ret join_then_else(fcx, antec, conseq, maybe_alt, e.id, plain_if,
                            pres);
       }
-      expr_ternary(_, _, _) {
-        ret find_pre_post_state_expr(fcx, pres, ternary_to_if(e));
-      }
       expr_binary(bop, l, r) {
         if lazy_binop(bop) {
             let changed = find_pre_post_state_expr(fcx, pres, l);
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index 567353bc0d9..de467009750 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -1921,9 +1921,6 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
             check_pred_expr(fcx, cond) |
                 check_then_else(fcx, thn, elsopt, id, expr.span);
       }
-      ast::expr_ternary(_, _, _) {
-        bot = check_expr(fcx, ast_util::ternary_to_if(expr));
-      }
       ast::expr_assert(e) {
         bot = check_expr_with(fcx, e, ty::mk_bool(tcx));
         write_nil(tcx, id);
diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs
index 4ff96c17daa..ee93a3e0e29 100644
--- a/src/comp/syntax/ast.rs
+++ b/src/comp/syntax/ast.rs
@@ -213,7 +213,6 @@ enum expr_ {
     expr_lit(@lit),
     expr_cast(@expr, @ty),
     expr_if(@expr, blk, option::t<@expr>),
-    expr_ternary(@expr, @expr, @expr),
     expr_while(@expr, blk),
     expr_for(@local, @expr, blk),
     expr_do_while(blk, @expr),
diff --git a/src/comp/syntax/ast_util.rs b/src/comp/syntax/ast_util.rs
index 32df1e95fdd..68b157cecb8 100644
--- a/src/comp/syntax/ast_util.rs
+++ b/src/comp/syntax/ast_util.rs
@@ -205,23 +205,6 @@ fn default_block(stmts1: [@stmt], expr1: option::t<@expr>, id1: node_id) ->
     {view_items: [], stmts: stmts1, expr: expr1, id: id1, rules: default_blk}
 }
 
-// This is a convenience function to transfor ternary expressions to if
-// expressions so that they can be treated the same
-fn ternary_to_if(e: @expr) -> @expr {
-    alt e.node {
-      expr_ternary(cond, then, els) {
-        let then_blk = block_from_expr(then);
-        let els_blk = block_from_expr(els);
-        let els_expr =
-            @{id: els.id, node: expr_block(els_blk), span: els.span};
-        ret @{id: e.id,
-              node: expr_if(cond, then_blk, option::some(els_expr)),
-              span: e.span};
-      }
-      _ { fail; }
-    }
-}
-
 // FIXME this doesn't handle big integer/float literals correctly (nor does
 // the rest of our literal handling)
 enum const_val {
diff --git a/src/comp/syntax/fold.rs b/src/comp/syntax/fold.rs
index b24f3aae473..a6e10d183c3 100644
--- a/src/comp/syntax/fold.rs
+++ b/src/comp/syntax/fold.rs
@@ -352,10 +352,6 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
             expr_if(fld.fold_expr(cond), fld.fold_block(tr),
                     option::map(fl, fld.fold_expr))
           }
-          expr_ternary(cond, tr, fl) {
-            expr_ternary(fld.fold_expr(cond), fld.fold_expr(tr),
-                         fld.fold_expr(fl))
-          }
           expr_while(cond, body) {
             expr_while(fld.fold_expr(cond), fld.fold_block(body))
           }
diff --git a/src/comp/syntax/parse/lexer.rs b/src/comp/syntax/parse/lexer.rs
index c7c0f32cff9..ae31f1b3434 100644
--- a/src/comp/syntax/parse/lexer.rs
+++ b/src/comp/syntax/parse/lexer.rs
@@ -328,10 +328,6 @@ fn next_token_inner(rdr: reader) -> token::token {
 
 
       // One-byte tokens.
-      '?' {
-        rdr.bump();
-        ret token::QUES;
-      }
       ';' { rdr.bump(); ret token::SEMI; }
       ',' { rdr.bump(); ret token::COMMA; }
       '.' {
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 9678c69b1df..272d65707dd 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -1097,18 +1097,6 @@ fn parse_prefix_expr(p: parser) -> pexpr {
     ret mk_pexpr(p, lo, hi, ex);
 }
 
-fn parse_ternary(p: parser) -> @ast::expr {
-    let cond_expr = parse_binops(p);
-    if p.token == token::QUES {
-        p.bump();
-        let then_expr = parse_expr(p);
-        expect(p, token::COLON);
-        let else_expr = parse_expr(p);
-        ret mk_expr(p, cond_expr.span.lo, else_expr.span.hi,
-                    ast::expr_ternary(cond_expr, then_expr, else_expr));
-    } else { ret cond_expr; }
-}
-
 type op_spec = {tok: token::token, op: ast::binop, prec: int};
 
 
@@ -1143,7 +1131,6 @@ fn parse_binops(p: parser) -> @ast::expr {
 const unop_prec: int = 100;
 
 const as_prec: int = 5;
-const ternary_prec: int = 0;
 
 fn parse_more_binops(p: parser, plhs: pexpr, min_prec: int) ->
    @ast::expr {
@@ -1174,7 +1161,7 @@ fn parse_more_binops(p: parser, plhs: pexpr, min_prec: int) ->
 
 fn parse_assign_expr(p: parser) -> @ast::expr {
     let lo = p.span.lo;
-    let lhs = parse_ternary(p);
+    let lhs = parse_binops(p);
     alt p.token {
       token::EQ {
         p.bump();
diff --git a/src/comp/syntax/parse/token.rs b/src/comp/syntax/parse/token.rs
index 0965697f8c8..3b38f314ecf 100644
--- a/src/comp/syntax/parse/token.rs
+++ b/src/comp/syntax/parse/token.rs
@@ -43,7 +43,6 @@ enum token {
     SEMI,
     COLON,
     MOD_SEP,
-    QUES,
     RARROW,
     LARROW,
     DARROW,
@@ -114,7 +113,6 @@ fn to_str(r: reader, t: token) -> str {
       SEMI { ret ";"; }
       COLON { ret ":"; }
       MOD_SEP { ret "::"; }
-      QUES { ret "?"; }
       RARROW { ret "->"; }
       LARROW { ret "<-"; }
       DARROW { ret "<->"; }
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index 5b62cef2d3b..94095b6ab40 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -855,15 +855,6 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
       ast::expr_if_check(test, blk, elseopt) {
         print_if(s, test, blk, elseopt, true);
       }
-      ast::expr_ternary(test, then, els) {
-        print_expr(s, test);
-        space(s.s);
-        word_space(s, "?");
-        print_expr(s, then);
-        space(s.s);
-        word_space(s, ":");
-        print_expr(s, els);
-      }
       ast::expr_while(test, blk) {
         head(s, "while");
         print_maybe_parens_discrim(s, test);
@@ -1044,8 +1035,8 @@ fn print_expr_parens_if_not_bot(s: ps, ex: @ast::expr) {
     let parens = alt ex.node {
       ast::expr_fail(_) | ast::expr_ret(_) |
       ast::expr_binary(_, _, _) | ast::expr_unary(_, _) |
-      ast::expr_ternary(_, _, _) | ast::expr_move(_, _) |
-      ast::expr_copy(_) | ast::expr_assign(_, _) | ast::expr_be(_) |
+      ast::expr_move(_, _) | ast::expr_copy(_) |
+      ast::expr_assign(_, _) | ast::expr_be(_) |
       ast::expr_assign_op(_, _, _) | ast::expr_swap(_, _) |
       ast::expr_log(_, _, _) | ast::expr_assert(_) |
       ast::expr_call(_, _, true) |
@@ -1395,7 +1386,6 @@ fn need_parens(expr: @ast::expr, outer_prec: int) -> bool {
     alt expr.node {
       ast::expr_binary(op, _, _) { operator_prec(op) < outer_prec }
       ast::expr_cast(_, _) { parse::parser::as_prec < outer_prec }
-      ast::expr_ternary(_, _, _) { parse::parser::ternary_prec < outer_prec }
       // This may be too conservative in some cases
       ast::expr_assign(_, _) { true }
       ast::expr_move(_, _) { true }
@@ -1757,8 +1747,8 @@ fn ends_in_lit_int(ex: @ast::expr) -> bool {
     alt ex.node {
       ast::expr_lit(@{node: ast::lit_int(_, ast::ty_i), _}) { true }
       ast::expr_binary(_, _, sub) | ast::expr_unary(_, sub) |
-      ast::expr_ternary(_, _, sub) | ast::expr_move(_, sub) |
-      ast::expr_copy(sub) | ast::expr_assign(_, sub) | ast::expr_be(sub) |
+      ast::expr_move(_, sub) | ast::expr_copy(sub) |
+      ast::expr_assign(_, sub) | ast::expr_be(sub) |
       ast::expr_assign_op(_, _, sub) | ast::expr_swap(_, sub) |
       ast::expr_log(_, _, sub) | ast::expr_assert(sub) |
       ast::expr_check(_, sub) { ends_in_lit_int(sub) }
diff --git a/src/comp/syntax/visit.rs b/src/comp/syntax/visit.rs
index ba995192859..1fb6991256e 100644
--- a/src/comp/syntax/visit.rs
+++ b/src/comp/syntax/visit.rs
@@ -312,11 +312,6 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
         v.visit_block(b, e, v);
         visit_expr_opt(eo, e, v);
       }
-      expr_ternary(c, t, el) {
-        v.visit_expr(c, e, v);
-        v.visit_expr(t, e, v);
-        v.visit_expr(el, e, v);
-      }
       expr_while(x, b) { v.visit_expr(x, e, v); v.visit_block(b, e, v); }
       expr_for(dcl, x, b) {
         v.visit_local(dcl, e, v);