Skip to content

Commit

Permalink
Add comparison operators to boolean const eval.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Oct 10, 2016
1 parent 9d4d0da commit f9c73ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/librustc_const_eval/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,10 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
hir::BiBitOr => a | b,
hir::BiEq => a == b,
hir::BiNe => a != b,
hir::BiLt => a < b,
hir::BiLe => a <= b,
hir::BiGe => a >= b,
hir::BiGt => a > b,
_ => signal!(e, InvalidOpForBools(op.node)),
})
}
Expand Down
4 changes: 4 additions & 0 deletions src/test/run-pass/const-err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ const X: *const u8 = b"" as _;
fn main() {
let _ = ((-1 as i8) << 8 - 1) as f32;
let _ = 0u8 as char;
let _ = true > false;
let _ = true >= false;
let _ = true < false;
let _ = true >= false;
}

0 comments on commit f9c73ad

Please sign in to comment.