Skip to content

Commit

Permalink
Update the rust toolchain to nightly-2024-04-03
Browse files Browse the repository at this point in the history
Changes required due to:
- rust-lang/rust@3da115a93b Add Ord::cmp for primitives as a BinOp in MIR

Resolves: #31XX
  • Loading branch information
tautschnig committed Apr 5, 2024
1 parent c4f16e9 commit e2856c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion kani-compiler/src/codegen_cprover_gotoc/codegen/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ impl<'tcx> GotocCtx<'tcx> {
BinOp::BitXor | BinOp::BitAnd | BinOp::BitOr => {
self.codegen_unchecked_scalar_binop(op, e1, e2)
}
BinOp::Eq | BinOp::Lt | BinOp::Le | BinOp::Ne | BinOp::Ge | BinOp::Gt => {
BinOp::Eq | BinOp::Lt | BinOp::Le | BinOp::Ne | BinOp::Ge | BinOp::Gt | BinOp::Cmp => {
let op_ty = self.operand_ty_stable(e1);
if self.is_fat_pointer_stable(op_ty) {
self.codegen_comparison_fat_ptr(op, e1, e2, loc)
Expand Down Expand Up @@ -1465,6 +1465,14 @@ fn comparison_expr(op: &BinOp, left: Expr, right: Expr, is_float: bool) -> Expr
}
BinOp::Ge => left.ge(right),
BinOp::Gt => left.gt(right),
BinOp::Cmp => {
// Implement https://doc.rust-lang.org/core/cmp/trait.Ord.html as done in cranelift,
// i.e., (left > right) - (left < right)
left.clone()
.gt(right.clone())
.cast_to(Type::c_int())
.sub(left.lt(right).cast_to(Type::c_int()))
}
_ => unreachable!(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT

[toolchain]
channel = "nightly-2024-03-29"
channel = "nightly-2024-04-03"
components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]
File renamed without changes.

0 comments on commit e2856c7

Please sign in to comment.