Skip to content

Commit 173594b

Browse files
Update to Rust edition 2024 (#4197)
Upstream change rust-lang/rust#143214 (Remove let_chains unstable feature) requires us to either remove the use of `let` in several places or wholesale update to Rust edition 2024. Doing this edition update seems worthwhile to keep accessing more recent features, but required code changes in several places. This is in preparation of the toolchain upgrade to 2025-07-03, but does not actually do this upgrade for it will require other, unrelated changes. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --------- Co-authored-by: Carolyn Zech <cmzech@amazon.com>
1 parent 1238681 commit 173594b

File tree

36 files changed

+142
-125
lines changed

36 files changed

+142
-125
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[package]
55
name = "kani-verifier"
66
version = "0.64.0"
7-
edition = "2021"
7+
edition = "2024"
88
description = "A bit-precise model checker for Rust."
99
readme = "README.md"
1010
keywords = ["model-checking", "verification"]

cprover_bindings/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[package]
55
name = "cprover_bindings"
66
version = "0.64.0"
7-
edition = "2021"
7+
edition = "2024"
88
license = "MIT OR Apache-2.0"
99
publish = false
1010

cprover_bindings/src/goto_program/typ.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ impl Type {
11311131
let concrete = self.unwrap_typedef();
11321132
match concrete {
11331133
CInteger(CIntType::SizeT) => Some(CInteger(CIntType::SSizeT)),
1134-
Unsignedbv { ref width } => Some(Signedbv { width: *width }),
1134+
Unsignedbv { width } => Some(Signedbv { width: *width }),
11351135
CInteger(CIntType::SSizeT) | Signedbv { .. } => Some(self.clone()),
11361136
_ => None,
11371137
}
@@ -1144,7 +1144,7 @@ impl Type {
11441144
let concrete = self.unwrap_typedef();
11451145
match concrete {
11461146
CInteger(CIntType::SSizeT) => Some(CInteger(CIntType::SizeT)),
1147-
Signedbv { ref width } => Some(Unsignedbv { width: *width }),
1147+
Signedbv { width } => Some(Unsignedbv { width: *width }),
11481148
CInteger(CIntType::SizeT) | Unsignedbv { .. } => Some(self.clone()),
11491149
_ => None,
11501150
}

kani-compiler/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[package]
55
name = "kani-compiler"
66
version = "0.64.0"
7-
edition = "2021"
7+
edition = "2024"
88
license = "MIT OR Apache-2.0"
99
publish = false
1010

kani-compiler/src/codegen_cprover_gotoc/codegen/operand.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ impl<'tcx> GotocCtx<'tcx> {
651651

652652
/// Ensure that the given instance is in the symbol table, returning the symbol.
653653
fn codegen_func_symbol(&mut self, instance: Instance) -> &Symbol {
654-
let sym = if instance.is_foreign_item() && !instance.has_body() {
654+
if instance.is_foreign_item() && !instance.has_body() {
655655
// Get the symbol that represents a foreign instance.
656656
self.codegen_foreign_fn(instance)
657657
} else {
@@ -661,8 +661,7 @@ impl<'tcx> GotocCtx<'tcx> {
661661
self.symbol_table
662662
.lookup(&func)
663663
.unwrap_or_else(|| panic!("Function `{func}` should've been declared before usage"))
664-
};
665-
sym
664+
}
666665
}
667666

668667
/// Generate a goto expression that references the function identified by `instance`.

kani-compiler/src/codegen_cprover_gotoc/codegen/rvalue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ impl GotocCtx<'_> {
857857
NullOp::ContractChecks | NullOp::UbChecks => Expr::c_false(),
858858
}
859859
}
860-
Rvalue::ShallowInitBox(ref operand, content_ty) => {
860+
Rvalue::ShallowInitBox(operand, content_ty) => {
861861
// The behaviour of ShallowInitBox is simply transmuting *mut u8 to Box<T>.
862862
// See https://github.com/rust-lang/compiler-team/issues/460 for more details.
863863
let operand = self.codegen_operand_stable(operand);
@@ -947,7 +947,7 @@ impl GotocCtx<'_> {
947947
let pt = self.place_ty_stable(p);
948948
self.codegen_get_discriminant(place, pt, res_ty)
949949
}
950-
Rvalue::Aggregate(ref k, operands) => {
950+
Rvalue::Aggregate(k, operands) => {
951951
self.codegen_rvalue_aggregate(k, operands, res_ty, loc)
952952
}
953953
Rvalue::ThreadLocalRef(def_id) => {

kani-compiler/src/codegen_cprover_gotoc/codegen/statement.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl GotocCtx<'_> {
216216
// https://doc.rust-lang.org/beta/nightly-rustc/rustc_middle/mir/enum.NonDivergingIntrinsic.html#variant.Assume
217217
// Informs the optimizer that a condition is always true.
218218
// If the condition is false, the behavior is undefined.
219-
StatementKind::Intrinsic(NonDivergingIntrinsic::Assume(ref op)) => {
219+
StatementKind::Intrinsic(NonDivergingIntrinsic::Assume(op)) => {
220220
let cond = self.codegen_operand_stable(op).cast_to(Type::bool());
221221
self.codegen_assert_assume(
222222
cond,

kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ impl<'tcx> GotocCtx<'tcx> {
17541754
&self,
17551755
instance: InstanceStable,
17561756
fn_abi: &'a FnAbi,
1757-
) -> impl Iterator<Item = (usize, &'a ArgAbi)> {
1757+
) -> impl Iterator<Item = (usize, &'a ArgAbi)> + use<'a> {
17581758
let requires_caller_location = self.requires_caller_location(instance);
17591759
let num_args = fn_abi.args.len();
17601760
fn_abi.args.iter().enumerate().filter(move |(idx, arg_abi)| {

kani-compiler/src/codegen_cprover_gotoc/context/goto_ctx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ impl GotocCtx<'_> {
451451
) -> Stmt {
452452
match stmt.body() {
453453
StmtBody::Return(Some(expr)) => {
454-
if let ExprValue::Symbol { ref identifier } = expr.value() {
454+
if let ExprValue::Symbol { identifier } = expr.value() {
455455
*return_symbol = Some(Expr::symbol_expression(*identifier, expr.typ().clone()));
456456
Stmt::goto(*end_label, *stmt.location())
457457
} else {

kani-compiler/src/kani_middle/resolve.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn resolve_path<'tcx>(
150150
path.segments.into_iter().try_fold(path.base, |base, segment| {
151151
let name = segment.ident.to_string();
152152
let def_kind = tcx.def_kind(base);
153-
let next_item = match def_kind {
153+
match def_kind {
154154
DefKind::ForeignMod | DefKind::Mod => resolve_in_module(tcx, base, &name),
155155
DefKind::Struct | DefKind::Enum | DefKind::Union => {
156156
resolve_in_type_def(tcx, base, &path.base_path_args, &name)
@@ -160,8 +160,7 @@ fn resolve_path<'tcx>(
160160
debug!(?base, ?kind, "resolve_path: unexpected item");
161161
Err(ResolveError::UnexpectedType { tcx, item: base, expected: "module" })
162162
}
163-
};
164-
next_item
163+
}
165164
})
166165
}
167166

0 commit comments

Comments
 (0)