Skip to content

Commit f9c73ad

Browse files
Add comparison operators to boolean const eval.
1 parent 9d4d0da commit f9c73ad

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/librustc_const_eval/eval.rs

+4
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,10 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
732732
hir::BiBitOr => a | b,
733733
hir::BiEq => a == b,
734734
hir::BiNe => a != b,
735+
hir::BiLt => a < b,
736+
hir::BiLe => a <= b,
737+
hir::BiGe => a >= b,
738+
hir::BiGt => a > b,
735739
_ => signal!(e, InvalidOpForBools(op.node)),
736740
})
737741
}

src/test/run-pass/const-err.rs

+4
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ const X: *const u8 = b"" as _;
1717
fn main() {
1818
let _ = ((-1 as i8) << 8 - 1) as f32;
1919
let _ = 0u8 as char;
20+
let _ = true > false;
21+
let _ = true >= false;
22+
let _ = true < false;
23+
let _ = true >= false;
2024
}

0 commit comments

Comments
 (0)