Skip to content

Commit 3a76044

Browse files
Paul Woolcockmarijnh
authored andcommitted
---
yaml --- r: 13902 b: refs/heads/try c: e1251f7 h: refs/heads/master v: v3
1 parent 8da1cc4 commit 3a76044

File tree

19 files changed

+184
-69
lines changed

19 files changed

+184
-69
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: e1f15a71e3dc1d24454594e068ed3df2271448e3
5+
refs/heads/try: e1251f7b0045281123dcbb1ffc80320b324bd814
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/comp/driver/driver.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,11 @@ fn host_triple() -> str {
333333
// grabbing (at compile time) the target triple that this rustc is
334334
// built with and calling that (at runtime) the host triple.
335335
let ht = #env("CFG_HOST_TRIPLE");
336-
ret ht != "" ? ht : fail "rustc built without CFG_HOST_TRIPLE";
336+
ret if ht != "" {
337+
ht
338+
} else {
339+
fail "rustc built without CFG_HOST_TRIPLE"
340+
};
337341
}
338342

339343
fn build_session_options(match: getopts::match,

branches/try/src/comp/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ fn mk_path(cx: test_ctxt, path: [ast::ident]) -> [ast::ident] {
244244
_ { false }
245245
}
246246
};
247-
(is_std ? [] : ["std"]) + path
247+
(if is_std { [] } else { ["std"] }) + path
248248
}
249249

250250
// The ast::ty of [std::test::test_desc]

branches/try/src/comp/middle/alias.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -602,23 +602,26 @@ fn pattern_roots(tcx: ty::ctxt, mut: option::t<unsafe_ty>, pat: @ast::pat)
602602
ast::pat_rec(fs, _) {
603603
let ty = ty::node_id_to_type(tcx, pat.id);
604604
for f in fs {
605-
let m = ty::get_field(tcx, ty, f.ident).mt.mut != ast::imm;
606-
walk(tcx, m ? some(contains(ty)) : mut, f.pat, set);
605+
let m = ty::get_field(tcx, ty, f.ident).mt.mut != ast::imm,
606+
c = if m { some(contains(ty)) } else { mut };
607+
walk(tcx, c, f.pat, set);
607608
}
608609
}
609610
ast::pat_box(p) {
610611
let ty = ty::node_id_to_type(tcx, pat.id);
611612
let m = alt ty::struct(tcx, ty) {
612613
ty::ty_box(mt) { mt.mut != ast::imm }
613-
};
614-
walk(tcx, m ? some(contains(ty)) : mut, p, set);
614+
},
615+
c = if m {some(contains(ty)) } else { mut };
616+
walk(tcx, c, p, set);
615617
}
616618
ast::pat_uniq(p) {
617619
let ty = ty::node_id_to_type(tcx, pat.id);
618620
let m = alt ty::struct(tcx, ty) {
619621
ty::ty_uniq(mt) { mt.mut != ast::imm }
620-
};
621-
walk(tcx, m ? some(contains(ty)) : mut, p, set);
622+
},
623+
c = if m { some(contains(ty)) } else { mut };
624+
walk(tcx, c, p, set);
622625
}
623626
}
624627
}

branches/try/src/comp/middle/check_const.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ fn check_expr(sess: session, method_map: typeck::method_map, e: @expr,
7373
expr_lit(@{node: lit_int(v, t), _}) {
7474
if t != ty_char {
7575
if (v as u64) > ast_util::int_ty_max(
76-
t == ty_i ? sess.targ_cfg.int_type : t) {
76+
if t == ty_i { sess.targ_cfg.int_type } else { t }) {
7777
sess.span_err(e.span, "literal out of range for its type");
7878
}
7979
}
8080
}
8181
expr_lit(@{node: lit_uint(v, t), _}) {
8282
if v > ast_util::uint_ty_max(
83-
t == ty_u ? sess.targ_cfg.uint_type : t) {
83+
if t == ty_u { sess.targ_cfg.uint_type } else { t }) {
8484
sess.span_err(e.span, "literal out of range for its type");
8585
}
8686
}

branches/try/src/comp/middle/debuginfo.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,16 @@ fn create_composite_type(type_tag: int, name: str, file: ValueRef, line: int,
465465
lli64(align), // align
466466
lli64(offset), // offset
467467
lli32(0), // flags
468-
option::is_none(derived) ? llnull() : // derived from
469-
option::get(derived),
470-
option::is_none(members) ? llnull() : // members
471-
llmdnode(option::get(members)),
468+
if option::is_none(derived) {
469+
llnull()
470+
} else { // derived from
471+
option::get(derived)
472+
},
473+
if option::is_none(members) {
474+
llnull()
475+
} else { //members
476+
llmdnode(option::get(members))
477+
},
472478
lli32(0), // runtime language
473479
llnull()
474480
];
@@ -776,7 +782,7 @@ fn create_function(fcx: @fn_ctxt) -> @metadata<subprogram_md> {
776782
let loc = codemap::lookup_char_pos(cx.sess.codemap,
777783
sp.lo);
778784
let file_node = create_file(cx, loc.filename).node;
779-
let key = cx.item_symbols.contains_key(fcx.id) ? fcx.id : id;
785+
let key = if cx.item_symbols.contains_key(fcx.id) { fcx.id } else { id };
780786
let mangled = cx.item_symbols.get(key);
781787
let ty_node = if cx.sess.opts.extra_debuginfo {
782788
alt ret_ty.node {

branches/try/src/comp/middle/resolve.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,7 +1986,7 @@ fn visit_block_with_impl_scope(e: @env, b: ast::blk, sc: iscopes,
19861986
_ {}
19871987
}
19881988
}
1989-
let sc = vec::len(impls) > 0u ? cons(@impls, @sc) : sc;
1989+
let sc = if vec::len(impls) > 0u { cons(@impls, @sc) } else { sc };
19901990
visit::visit_block(b, sc, v);
19911991
}
19921992

@@ -1998,8 +1998,11 @@ fn visit_mod_with_impl_scope(e: @env, m: ast::_mod, s: span, id: node_id,
19981998
}
19991999
for i in m.items { find_impls_in_item(*e, i, impls, none, none); }
20002000
let impls = @impls;
2001-
visit::visit_mod(m, s, id,
2002-
vec::len(*impls) > 0u ? cons(impls, @sc) : sc, v);
2001+
visit::visit_mod(m, s, id, if vec::len(*impls) > 0u {
2002+
cons(impls, @sc)
2003+
} else {
2004+
sc
2005+
}, v);
20032006
e.impl_map.insert(id, cons(impls, @nil));
20042007
}
20052008

branches/try/src/comp/middle/trans/alt.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,11 @@ fn compile_submatch(bcx: @block_ctxt, m: match, vals: [ValueRef], f: mk_fail,
402402

403403
let col = pick_col(m);
404404
let val = vals[col];
405-
let m = has_nested_bindings(m, col) ?
406-
expand_nested_bindings(m, col, val) : m;
405+
let m = if has_nested_bindings(m, col) {
406+
expand_nested_bindings(m, col, val)
407+
} else {
408+
m
409+
};
407410

408411
let vals_left =
409412
vec::slice(vals, 0u, col) +
@@ -493,7 +496,11 @@ fn compile_submatch(bcx: @block_ctxt, m: match, vals: [ValueRef], f: mk_fail,
493496
lit(l) {
494497
test_val = Load(bcx, val);
495498
let pty = ty::node_id_to_type(ccx.tcx, pat_id);
496-
kind = ty::type_is_integral(ccx.tcx, pty) ? switch : compare;
499+
kind = if ty::type_is_integral(ccx.tcx, pty) {
500+
switch
501+
} else {
502+
compare
503+
};
497504
}
498505
range(_, _) {
499506
test_val = Load(bcx, val);

branches/try/src/comp/middle/trans/base.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn type_of_explicit_args(cx: @crate_ctxt, inputs: [ty::arg]) ->
6868
// that would obviate the need for this check
6969
check non_ty_var(cx, arg_ty);
7070
let llty = type_of_inner(cx, arg_ty);
71-
atys += [arg.mode == ast::by_val ? llty : T_ptr(llty)];
71+
atys += [if arg.mode == ast::by_val { llty } else { T_ptr(llty) }];
7272
}
7373
ret atys;
7474
}
@@ -2015,8 +2015,11 @@ fn store_temp_expr(cx: @block_ctxt, action: copy_action, dst: ValueRef,
20152015
-> @block_ctxt {
20162016
// Lvals in memory are not temporaries. Copy them.
20172017
if src.kind != temporary && !last_use {
2018-
let v = src.kind == owned ? load_if_immediate(cx, src.val, t)
2019-
: src.val;
2018+
let v = if src.kind == owned {
2019+
load_if_immediate(cx, src.val, t)
2020+
} else {
2021+
src.val
2022+
};
20202023
ret copy_val(cx, action, dst, v, t);
20212024
}
20222025
ret move_val(cx, action, dst, src, t);
@@ -3417,7 +3420,7 @@ fn trans_expr_save_in(bcx: @block_ctxt, e: @ast::expr, dest: ValueRef)
34173420
-> @block_ctxt {
34183421
let tcx = bcx_tcx(bcx), t = ty::expr_ty(tcx, e);
34193422
let do_ignore = ty::type_is_bot(tcx, t) || ty::type_is_nil(tcx, t);
3420-
ret trans_expr(bcx, e, do_ignore ? ignore : save_in(dest));
3423+
ret trans_expr(bcx, e, if do_ignore { ignore } else { save_in(dest) });
34213424
}
34223425

34233426
// Call this to compile an expression that you need as an intermediate value,
@@ -4256,7 +4259,7 @@ fn trans_block_dps(bcx: @block_ctxt, b: ast::blk, dest: dest)
42564259
some(e) {
42574260
let bt = ty::type_is_bot(bcx_tcx(bcx), ty::expr_ty(bcx_tcx(bcx), e));
42584261
debuginfo::update_source_pos(bcx, e.span);
4259-
bcx = trans_expr(bcx, e, bt ? ignore : dest);
4262+
bcx = trans_expr(bcx, e, if bt { ignore } else { dest });
42604263
}
42614264
_ { assert dest == ignore || bcx.unreachable; }
42624265
}
@@ -4493,7 +4496,11 @@ fn trans_fn(cx: @local_ctxt, sp: span, decl: ast::fn_decl, body: ast::blk,
44934496
llfndecl: ValueRef, ty_self: self_arg, ty_params: [ast::ty_param],
44944497
id: ast::node_id) {
44954498
let do_time = cx.ccx.sess.opts.stats;
4496-
let start = do_time ? time::get_time() : {sec: 0u32, usec: 0u32};
4499+
let start = if do_time {
4500+
time::get_time()
4501+
} else {
4502+
{sec: 0u32, usec: 0u32}
4503+
};
44974504
let fcx = option::none;
44984505
trans_closure(cx, sp, decl, body, llfndecl, ty_self, ty_params, id,
44994506
{|new_fcx| fcx = option::some(new_fcx);});
@@ -5396,7 +5403,7 @@ fn decl_crate_map(sess: session::session, mapname: str,
53965403
let n_subcrates = 1;
53975404
let cstore = sess.cstore;
53985405
while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; }
5399-
let mapname = sess.building_library ? mapname : "toplevel";
5406+
let mapname = if sess.building_library { mapname } else { "toplevel" };
54005407
let sym_name = "_rust_crate_map_" + mapname;
54015408
let arrtype = T_array(int_type, n_subcrates as uint);
54025409
let maptype = T_struct([int_type, arrtype]);

branches/try/src/comp/middle/trans/tvec.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,13 @@ fn trans_append(cx: @block_ctxt, vec_ty: ty::t, lhsptr: ValueRef,
149149
let ccx = bcx_ccx(cx);
150150
let unit_ty = ty::sequence_element_type(bcx_tcx(cx), vec_ty);
151151
let dynamic = ty::type_has_dynamic_size(bcx_tcx(cx), unit_ty);
152-
let (lhsptr, rhs) = !dynamic ? (lhsptr, rhs) :
153-
(PointerCast(cx, lhsptr, T_ptr(T_ptr(ccx.opaque_vec_type))),
154-
PointerCast(cx, rhs, T_ptr(ccx.opaque_vec_type)));
152+
let (lhsptr, rhs) =
153+
if !dynamic {
154+
(lhsptr, rhs)
155+
} else {
156+
(PointerCast(cx, lhsptr, T_ptr(T_ptr(ccx.opaque_vec_type))),
157+
PointerCast(cx, rhs, T_ptr(ccx.opaque_vec_type)))
158+
};
155159
let strings = alt ty::struct(bcx_tcx(cx), vec_ty) {
156160
ty::ty_str { true }
157161
ty::ty_vec(_) { false }
@@ -187,7 +191,11 @@ fn trans_append(cx: @block_ctxt, vec_ty: ty::t, lhsptr: ValueRef,
187191
copy_val(bcx, INIT, write_ptr,
188192
load_if_immediate(bcx, addr, unit_ty),
189193
unit_ty);
190-
let incr = dynamic ? unit_sz : C_int(ccx, 1);
194+
let incr = if dynamic {
195+
unit_sz
196+
} else {
197+
C_int(ccx, 1)
198+
};
191199
Store(bcx, InBoundsGEP(bcx, write_ptr, [incr]),
192200
write_ptr_ptr);
193201
ret bcx;
@@ -244,8 +252,11 @@ fn trans_add(bcx: @block_ctxt, vec_ty: ty::t, lhs: ValueRef,
244252
let bcx = copy_val(bcx, INIT, write_ptr,
245253
load_if_immediate(bcx, addr, unit_ty), unit_ty);
246254
let incr =
247-
ty::type_has_dynamic_size(bcx_tcx(bcx), unit_ty) ?
248-
llunitsz : C_int(ccx, 1);
255+
if ty::type_has_dynamic_size(bcx_tcx(bcx), unit_ty) {
256+
llunitsz
257+
} else {
258+
C_int(ccx, 1)
259+
};
249260
Store(bcx, InBoundsGEP(bcx, write_ptr, [incr]),
250261
write_ptr_ptr);
251262
ret bcx;

branches/try/src/comp/middle/typeck.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,9 +1578,17 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
15781578
fcx.ccx.tcx.sess.span_err(
15791579
sp, #fmt["this function takes %u parameter%s but %u \
15801580
parameter%s supplied", expected_arg_count,
1581-
expected_arg_count == 1u ? "" : "s",
1581+
if expected_arg_count == 1u {
1582+
""
1583+
} else {
1584+
"s"
1585+
},
15821586
supplied_arg_count,
1583-
supplied_arg_count == 1u ? " was" : "s were"]);
1587+
if supplied_arg_count == 1u {
1588+
" was"
1589+
} else {
1590+
"s were"
1591+
}]);
15841592
// HACK: build an arguments list with dummy arguments to
15851593
// check against
15861594
let dummy = {mode: ast::by_ref, ty: ty::mk_bot(fcx.ccx.tcx)};

branches/try/src/comp/syntax/ast_util.rs

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,42 @@ fn lit_to_const(lit: @lit) -> const_val {
305305

306306
fn compare_const_vals(a: const_val, b: const_val) -> int {
307307
alt (a, b) {
308-
(const_int(a), const_int(b)) { a == b ? 0 : a < b ? -1 : 1 }
309-
(const_uint(a), const_uint(b)) { a == b ? 0 : a < b ? -1 : 1 }
310-
(const_float(a), const_float(b)) { a == b ? 0 : a < b ? -1 : 1 }
311-
(const_str(a), const_str(b)) { a == b ? 0 : a < b ? -1 : 1 }
308+
(const_int(a), const_int(b)) {
309+
if a == b {
310+
0
311+
} else if a < b {
312+
-1
313+
} else {
314+
1
315+
}
316+
}
317+
(const_uint(a), const_uint(b)) {
318+
if a == b {
319+
0
320+
} else if a < b {
321+
-1
322+
} else {
323+
1
324+
}
325+
}
326+
(const_float(a), const_float(b)) {
327+
if a == b {
328+
0
329+
} else if a < b {
330+
-1
331+
} else {
332+
1
333+
}
334+
}
335+
(const_str(a), const_str(b)) {
336+
if a == b {
337+
0
338+
} else if a < b {
339+
-1
340+
} else {
341+
1
342+
}
343+
}
312344
}
313345
}
314346

branches/try/src/comp/syntax/parse/lexer.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,31 +197,31 @@ fn scan_number(c: char, rdr: reader) -> token::token {
197197
c = rdr.curr;
198198
n = rdr.next();
199199
if c == 'u' || c == 'i' {
200-
let signed = c == 'i', tp = signed ? either::left(ast::ty_i)
201-
: either::right(ast::ty_u);
200+
let signed = c == 'i', tp = if signed { either::left(ast::ty_i) }
201+
else { either::right(ast::ty_u) };
202202
rdr.bump();
203203
c = rdr.curr;
204204
if c == '8' {
205205
rdr.bump();
206-
tp = signed ? either::left(ast::ty_i8)
207-
: either::right(ast::ty_u8);
206+
tp = if signed { either::left(ast::ty_i8) }
207+
else { either::right(ast::ty_u8) };
208208
}
209209
n = rdr.next();
210210
if c == '1' && n == '6' {
211211
rdr.bump();
212212
rdr.bump();
213-
tp = signed ? either::left(ast::ty_i16)
214-
: either::right(ast::ty_u16);
213+
tp = if signed { either::left(ast::ty_i16) }
214+
else { either::right(ast::ty_u16) };
215215
} else if c == '3' && n == '2' {
216216
rdr.bump();
217217
rdr.bump();
218-
tp = signed ? either::left(ast::ty_i32)
219-
: either::right(ast::ty_u32);
218+
tp = if signed { either::left(ast::ty_i32) }
219+
else { either::right(ast::ty_u32) };
220220
} else if c == '6' && n == '4' {
221221
rdr.bump();
222222
rdr.bump();
223-
tp = signed ? either::left(ast::ty_i64)
224-
: either::right(ast::ty_u64);
223+
tp = if signed { either::left(ast::ty_i64) }
224+
else { either::right(ast::ty_u64) };
225225
}
226226
let parsed = u64::from_str(num_str, base as u64);
227227
alt tp {

0 commit comments

Comments
 (0)