Skip to content

Commit 40c1b86

Browse files
committed
Use or-patterns in trans::trans_compare, eliminating a FIXME
1 parent 091a2c2 commit 40c1b86

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/comp/middle/trans.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,29 +2720,22 @@ fn trans_compare(cx0: &@block_ctxt, op: ast::binop, t0: &ty::t,
27202720
let rhs = rhs_r.val;
27212721
cx = rhs_r.bcx;
27222722
// Determine the operation we need.
2723-
// FIXME: Use or-patterns when we have them.
27242723

27252724
let llop;
27262725
alt op {
2727-
ast::eq. { llop = C_u8(abi::cmp_glue_op_eq); }
2728-
ast::lt. { llop = C_u8(abi::cmp_glue_op_lt); }
2729-
ast::le. { llop = C_u8(abi::cmp_glue_op_le); }
2730-
ast::ne. { llop = C_u8(abi::cmp_glue_op_eq); }
2731-
ast::ge. { llop = C_u8(abi::cmp_glue_op_lt); }
2732-
ast::gt. { llop = C_u8(abi::cmp_glue_op_le); }
2726+
ast::eq. | ast::ne. { llop = C_u8(abi::cmp_glue_op_eq); }
2727+
ast::lt. | ast::ge. { llop = C_u8(abi::cmp_glue_op_lt); }
2728+
ast::le. | ast::gt. { llop = C_u8(abi::cmp_glue_op_le); }
27332729
}
27342730
let rs = compare(cx, lhs, rhs, rhs_r.ty, llop);
27352731

27362732

27372733
// Invert the result if necessary.
2738-
// FIXME: Use or-patterns when we have them.
27392734
alt op {
2740-
ast::eq. { ret rslt(rs.bcx, rs.val); }
2741-
ast::lt. { ret rslt(rs.bcx, rs.val); }
2742-
ast::le. { ret rslt(rs.bcx, rs.val); }
2743-
ast::ne. { ret rslt(rs.bcx, rs.bcx.build.Not(rs.val)); }
2744-
ast::ge. { ret rslt(rs.bcx, rs.bcx.build.Not(rs.val)); }
2745-
ast::gt. { ret rslt(rs.bcx, rs.bcx.build.Not(rs.val)); }
2735+
ast::eq. | ast::lt. | ast::le. { ret rslt(rs.bcx, rs.val); }
2736+
ast::ne. | ast::ge. | ast::gt. {
2737+
ret rslt(rs.bcx, rs.bcx.build.Not(rs.val));
2738+
}
27462739
}
27472740
}
27482741

0 commit comments

Comments
 (0)