Skip to content

Commit 7e9f98a

Browse files
committed
rustc: Make range literals use compare_scalar_types instead of trans_compare
1 parent 5eccf84 commit 7e9f98a

File tree

2 files changed

+6
-32
lines changed

2 files changed

+6
-32
lines changed

src/rustc/middle/trans/alt.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,12 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
672672
Result {val: vbegin, _},
673673
Result {bcx, val: vend}) =>
674674
{
675-
let Result {bcx, val: llge} = trans_compare(
676-
bcx, ast::ge, test_val, t, vbegin, t);
677-
let Result {bcx, val: llle} = trans_compare(
678-
bcx, ast::le, test_val, t, vend, t);
675+
let Result {bcx, val: llge} =
676+
compare_scalar_types(bcx, test_val,
677+
vbegin, t, ast::ge);
678+
let Result {bcx, val: llle} =
679+
compare_scalar_types(bcx, test_val, vend,
680+
t, ast::le);
679681
rslt(bcx, And(bcx, llge, llle))
680682
}
681683
}

src/rustc/middle/trans/base.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -610,34 +610,6 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
610610
return cx;
611611
}
612612

613-
fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef,
614-
_lhs_t: ty::t, rhs: ValueRef, rhs_t: ty::t) -> Result {
615-
let _icx = cx.insn_ctxt("trans_compare");
616-
if ty::type_is_scalar(rhs_t) {
617-
let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, op);
618-
return rslt(rs.bcx, rs.val);
619-
}
620-
621-
// Determine the operation we need.
622-
let llop = {
623-
match op {
624-
ast::eq | ast::ne => C_u8(abi::cmp_glue_op_eq),
625-
ast::lt | ast::ge => C_u8(abi::cmp_glue_op_lt),
626-
ast::le | ast::gt => C_u8(abi::cmp_glue_op_le),
627-
_ => cx.tcx().sess.bug(~"trans_compare got non-comparison-op")
628-
}
629-
};
630-
631-
let cmpval = glue::call_cmp_glue(cx, lhs, rhs, rhs_t, llop);
632-
633-
// Invert the result if necessary.
634-
match op {
635-
ast::eq | ast::lt | ast::le => rslt(cx, cmpval),
636-
ast::ne | ast::ge | ast::gt => rslt(cx, Not(cx, cmpval)),
637-
_ => cx.tcx().sess.bug(~"trans_compare got non-comparison-op")
638-
}
639-
}
640-
641613
fn cast_shift_expr_rhs(cx: block, op: ast::binop,
642614
lhs: ValueRef, rhs: ValueRef) -> ValueRef {
643615
cast_shift_rhs(op, lhs, rhs,

0 commit comments

Comments
 (0)