Skip to content

Commit

Permalink
Rollup merge of rust-lang#37056 - Mark-Simulacrum:fix-bool-comparison…
Browse files Browse the repository at this point in the history
…, r=bluss

Add comparison operators to boolean const eval.

I think it might be worth adding tests here, but since I don't know how or where to do that, I have not done so yet. Willing to do so if asked and given an explanation as to how.

Fixes rust-lang#37047.
  • Loading branch information
alexcrichton committed Oct 12, 2016
2 parents 5ac7f4f + f9c73ad commit a0ad661
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 a0ad661

Please sign in to comment.