From 36a09e825b50bd592ef8b15d87ae52e7d61f556e Mon Sep 17 00:00:00 2001 From: Zyad Hassan Date: Tue, 27 Dec 2022 18:34:14 -0800 Subject: [PATCH] Clippy fixes for upcoming rust toolchain update --- cprover_bindings/src/goto_program/expr.rs | 69 +++++-------------- cprover_bindings/src/goto_program/stmt.rs | 4 +- cprover_bindings/src/goto_program/symbol.rs | 4 +- cprover_bindings/src/goto_program/typ.rs | 24 ++----- .../src/codegen_cprover_gotoc/archive.rs | 3 +- .../codegen_cprover_gotoc/codegen/assert.rs | 3 +- .../codegen/intrinsic.rs | 8 +-- .../codegen_cprover_gotoc/codegen/operand.rs | 2 +- .../codegen_cprover_gotoc/codegen/place.rs | 3 +- .../codegen_cprover_gotoc/codegen/rvalue.rs | 3 +- .../src/codegen_cprover_gotoc/codegen/typ.rs | 11 +-- .../compiler_interface.rs | 5 +- kani-compiler/src/kani_middle/provide.rs | 2 +- kani-compiler/src/kani_middle/reachability.rs | 5 +- .../src/kani_middle/stubbing/annotations.rs | 2 +- kani-compiler/src/session.rs | 3 +- kani-driver/src/args.rs | 3 +- kani-driver/src/assess/mod.rs | 2 +- kani-driver/src/call_cargo.rs | 2 +- kani-driver/src/cbmc_property_renderer.rs | 11 ++- kani-driver/src/concrete_playback.rs | 6 +- kani-driver/src/harness_runner.rs | 3 +- library/kani_macros/src/derive.rs | 3 +- src/lib.rs | 2 +- tools/bookrunner/librustdoc/doctest.rs | 3 +- tools/build-kani/src/sysroot.rs | 2 +- tools/compiletest/src/json.rs | 3 +- 27 files changed, 57 insertions(+), 134 deletions(-) diff --git a/cprover_bindings/src/goto_program/expr.rs b/cprover_bindings/src/goto_program/expr.rs index 892e1c27ce11..5fa9ede910ee 100644 --- a/cprover_bindings/src/goto_program/expr.rs +++ b/cprover_bindings/src/goto_program/expr.rs @@ -433,9 +433,7 @@ impl Expr { assert_eq!(size as usize, elems.len()); assert!( elems.iter().all(|x| x.typ == *value_typ), - "Array type and value types don't match: \n{:?}\n{:?}", - typ, - elems + "Array type and value types don't match: \n{typ:?}\n{elems:?}" ); } else { unreachable!("Can't make an array_val with non-array target type {:?}", typ); @@ -448,9 +446,7 @@ impl Expr { assert_eq!(size as usize, elems.len()); assert!( elems.iter().all(|x| x.typ == *value_typ), - "Vector type and value types don't match: \n{:?}\n{:?}", - typ, - elems + "Vector type and value types don't match: \n{typ:?}\n{elems:?}" ); } else { unreachable!("Can't make a vector_val with non-vector target type {:?}", typ); @@ -642,9 +638,7 @@ impl Expr { pub fn call(self, arguments: Vec) -> Self { assert!( Expr::typecheck_call(&self, &arguments), - "Function call does not type check:\nfunc: {:?}\nargs: {:?}", - self, - arguments + "Function call does not type check:\nfunc: {self:?}\nargs: {arguments:?}" ); let typ = self.typ().return_type().unwrap().clone(); expr!(FunctionCall { function: self, arguments }, typ) @@ -658,9 +652,7 @@ impl Expr { let field: InternedString = field.into(); assert!( self.typ.is_struct_tag() || self.typ.is_union_tag(), - "Can't apply .member operation to\n\t{:?}\n\t{}", - self, - field, + "Can't apply .member operation to\n\t{self:?}\n\t{field}", ); if let Some(ty) = self.typ.lookup_field_type(field, symbol_table) { expr!(Member { lhs: self, field }, ty) @@ -701,10 +693,7 @@ impl Expr { // Check that each formal field has an value assert!( fields.iter().zip(values.iter()).all(|(f, v)| f.typ() == *v.typ()), - "Error in struct_expr; value type does not match field type.\n\t{:?}\n\t{:?}\n\t{:?}", - typ, - fields, - values + "Error in struct_expr; value type does not match field type.\n\t{typ:?}\n\t{fields:?}\n\t{values:?}" ); expr!(Struct { values }, typ) } @@ -720,18 +709,14 @@ impl Expr { ) -> Self { assert!( typ.is_struct_tag(), - "Error in struct_expr; must be given a struct_tag.\n\t{:?}\n\t{:?}", - typ, - components + "Error in struct_expr; must be given a struct_tag.\n\t{typ:?}\n\t{components:?}" ); let fields = typ.lookup_components(symbol_table).unwrap(); let non_padding_fields: Vec<_> = fields.iter().filter(|x| !x.is_padding()).collect(); assert_eq!( non_padding_fields.len(), components.len(), - "Error in struct_expr; mismatch in number of fields and components.\n\t{:?}\n\t{:?}", - typ, - components + "Error in struct_expr; mismatch in number of fields and components.\n\t{typ:?}\n\t{components:?}" ); // Check that each formal field has an value @@ -790,28 +775,21 @@ impl Expr { ) -> Self { assert!( typ.is_struct_tag(), - "Error in struct_expr; must be given struct_tag.\n\t{:?}\n\t{:?}", - typ, - non_padding_values + "Error in struct_expr; must be given struct_tag.\n\t{typ:?}\n\t{non_padding_values:?}" ); let fields = typ.lookup_components(symbol_table).unwrap(); let non_padding_fields: Vec<_> = fields.iter().filter(|x| !x.is_padding()).collect(); assert_eq!( non_padding_fields.len(), non_padding_values.len(), - "Error in struct_expr; mismatch in number of fields and values.\n\t{:?}\n\t{:?}", - typ, - non_padding_values + "Error in struct_expr; mismatch in number of fields and values.\n\t{typ:?}\n\t{non_padding_values:?}" ); assert!( non_padding_fields .iter() .zip(non_padding_values.iter()) .all(|(f, v)| f.field_typ().unwrap() == v.typ()), - "Error in struct_expr; value type does not match field type.\n\t{:?}\n\t{:?}\n\t{:?}", - typ, - non_padding_fields, - non_padding_values + "Error in struct_expr; value type does not match field type.\n\t{typ:?}\n\t{non_padding_fields:?}\n\t{non_padding_values:?}" ); let values = fields @@ -834,25 +812,18 @@ impl Expr { ) -> Self { assert!( typ.is_struct_tag() || typ.is_struct(), - "Error in struct_expr; must be given struct.\n\t{:?}\n\t{:?}", - typ, - values + "Error in struct_expr; must be given struct.\n\t{typ:?}\n\t{values:?}" ); let typ = typ.aggr_tag().unwrap(); let fields = typ.lookup_components(symbol_table).unwrap(); assert_eq!( fields.len(), values.len(), - "Error in struct_expr; mismatch in number of padded fields and padded values.\n\t{:?}\n\t{:?}", - typ, - values + "Error in struct_expr; mismatch in number of padded fields and padded values.\n\t{typ:?}\n\t{values:?}" ); assert!( fields.iter().zip(values.iter()).all(|(f, v)| &f.typ() == v.typ()), - "Error in struct_expr; value type does not match field type.\n\t{:?}\n\t{:?}\n\t{:?}", - typ, - fields, - values + "Error in struct_expr; value type does not match field type.\n\t{typ:?}\n\t{fields:?}\n\t{values:?}" ); Expr::struct_expr_with_explicit_padding(typ, fields, values) @@ -1028,10 +999,7 @@ impl Expr { pub fn binop(self, op: BinaryOperator, rhs: Expr) -> Expr { assert!( Expr::typecheck_binop_args(op, &self, &rhs), - "BinaryOperation Expression does not typecheck {:?} {:?} {:?}", - op, - self, - rhs + "BinaryOperation Expression does not typecheck {op:?} {self:?} {rhs:?}" ); expr!(BinOp { op, lhs: self, rhs }, Expr::binop_return_type(op, &self, &rhs)) } @@ -1041,10 +1009,7 @@ impl Expr { pub fn vector_cmp(self, op: BinaryOperator, rhs: Expr, ret_typ: Type) -> Expr { assert!( Expr::typecheck_vector_cmp_expr(&self, &rhs, &ret_typ), - "vector comparison expression does not typecheck {:?} {:?} {:?}", - self, - rhs, - ret_typ, + "vector comparison expression does not typecheck {self:?} {rhs:?} {ret_typ:?}", ); expr!(BinOp { op, lhs: self, rhs }, ret_typ) } @@ -1483,9 +1448,7 @@ impl Expr { pub fn reinterpret_cast(self, t: Type) -> Expr { assert!( self.can_take_address_of(), - "Can't take address of {:?} when coercing to {:?}", - self, - t + "Can't take address of {self:?} when coercing to {t:?}" ); self.address_of().cast_to(t.to_pointer()).dereference() } diff --git a/cprover_bindings/src/goto_program/stmt.rs b/cprover_bindings/src/goto_program/stmt.rs index f54fa4127f27..58755a0bffae 100644 --- a/cprover_bindings/src/goto_program/stmt.rs +++ b/cprover_bindings/src/goto_program/stmt.rs @@ -264,9 +264,7 @@ impl Stmt { ) -> Self { assert!( Expr::typecheck_call(&function, &arguments), - "Function call does not type check:\nfunc: {:?}\nargs: {:?}", - function, - arguments + "Function call does not type check:\nfunc: {function:?}\nargs: {arguments:?}" ); if let Some(lhs) = &lhs { assert_eq!(lhs.typ(), function.typ().return_type().unwrap()) diff --git a/cprover_bindings/src/goto_program/symbol.rs b/cprover_bindings/src/goto_program/symbol.rs index ae189144a85f..7f74abaa9816 100644 --- a/cprover_bindings/src/goto_program/symbol.rs +++ b/cprover_bindings/src/goto_program/symbol.rs @@ -74,9 +74,7 @@ impl Symbol { // See https://github.com/model-checking/kani/issues/1361#issuecomment-1181499683 assert!( name.to_string().ends_with(&base_name.map_or(String::new(), |s| s.to_string())), - "Symbol's base_name must be the suffix of its name.\nName: {:?}\nBase name: {:?}", - name, - base_name + "Symbol's base_name must be the suffix of its name.\nName: {name:?}\nBase name: {base_name:?}" ); Symbol { name, diff --git a/cprover_bindings/src/goto_program/typ.rs b/cprover_bindings/src/goto_program/typ.rs index 15a6419a0ee9..66c51fd9114c 100644 --- a/cprover_bindings/src/goto_program/typ.rs +++ b/cprover_bindings/src/goto_program/typ.rs @@ -191,9 +191,7 @@ impl DatatypeComponent { let name = name.into(); assert!( Self::typecheck_datatype_field(&typ), - "Illegal field.\n\tName: {}\n\tType: {:?}", - name, - typ + "Illegal field.\n\tName: {name}\n\tType: {typ:?}" ); Field { name, typ } } @@ -942,13 +940,7 @@ impl Type { identifier: Option, base_name: Option, ) -> Parameter { - assert!( - self.can_be_lvalue(), - "Expected lvalue from {:?} {:?} {:?}", - self, - identifier, - base_name - ); + assert!(self.can_be_lvalue(), "Expected lvalue from {self:?} {identifier:?} {base_name:?}"); Parameter { identifier, base_name, typ: self } } @@ -1133,13 +1125,11 @@ impl Type { ) -> Self { assert!( Type::components_are_unique(&components), - "Components contain duplicates: {:?}", - components + "Components contain duplicates: {components:?}" ); assert!( Type::components_in_valid_order_for_struct(&components), - "Components are not in valid order for struct: {:?}", - components + "Components are not in valid order for struct: {components:?}" ); let tag = tag.into(); @@ -1168,13 +1158,11 @@ impl Type { let tag = tag.into(); assert!( Type::components_are_unique(&components), - "Components contain duplicates: {:?}", - components + "Components contain duplicates: {components:?}" ); assert!( Type::components_are_not_flexible_array(&components), - "Unions cannot contain flexible arrays: {:?}", - components + "Unions cannot contain flexible arrays: {components:?}" ); Union { tag, components } } diff --git a/kani-compiler/src/codegen_cprover_gotoc/archive.rs b/kani-compiler/src/codegen_cprover_gotoc/archive.rs index 805de1ec27a7..2bf3e2c8380c 100644 --- a/kani-compiler/src/codegen_cprover_gotoc/archive.rs +++ b/kani-compiler/src/codegen_cprover_gotoc/archive.rs @@ -45,8 +45,7 @@ impl<'a> ArchiveBuilder<'a> { BuilderKind::Gnu(ar::GnuBuilder::new( File::create(&output).unwrap_or_else(|err| { sess.fatal(&format!( - "error opening destination during archive building: {}", - err + "error opening destination during archive building: {err}" )); }), self.entries.iter().map(|(name, _)| name.clone()).collect(), diff --git a/kani-compiler/src/codegen_cprover_gotoc/codegen/assert.rs b/kani-compiler/src/codegen_cprover_gotoc/codegen/assert.rs index ee7dff9191db..8dfb31af85cc 100644 --- a/kani-compiler/src/codegen_cprover_gotoc/codegen/assert.rs +++ b/kani-compiler/src/codegen_cprover_gotoc/codegen/assert.rs @@ -297,8 +297,7 @@ impl<'tcx> GotocCtx<'tcx> { "https://github.com/model-checking/kani/issues/new?template=bug_report.md"; let assert_msg = format!( - "Kani-internal sanity check: {}. Please report failures:\n{}", - message, BUG_REPORT_URL + "Kani-internal sanity check: {message}. Please report failures:\n{BUG_REPORT_URL}" ); self.codegen_assert_assume(cond, PropertyClass::SanityCheck, &assert_msg, loc) diff --git a/kani-compiler/src/codegen_cprover_gotoc/codegen/intrinsic.rs b/kani-compiler/src/codegen_cprover_gotoc/codegen/intrinsic.rs index 11bcfa471b84..a906b5567714 100644 --- a/kani-compiler/src/codegen_cprover_gotoc/codegen/intrinsic.rs +++ b/kani-compiler/src/codegen_cprover_gotoc/codegen/intrinsic.rs @@ -1499,8 +1499,7 @@ impl<'tcx> GotocCtx<'tcx> { if !ret_typ.base_type().unwrap().is_integer() { let (_, rust_base_type) = rust_ret_type.simd_size_and_type(self.tcx); let err_msg = format!( - "expected return type with integer elements, found `{}` with non-integer `{}`", - rust_ret_type, rust_base_type, + "expected return type with integer elements, found `{rust_ret_type}` with non-integer `{rust_base_type}`", ); self.tcx.sess.span_err(span.unwrap(), err_msg); } @@ -1541,7 +1540,7 @@ impl<'tcx> GotocCtx<'tcx> { let check_stmt = self.codegen_assert_assume( check.not(), PropertyClass::ArithmeticOverflow, - format!("attempt to compute {} which would overflow", intrinsic).as_str(), + format!("attempt to compute {intrinsic} which would overflow").as_str(), loc, ); let res = op_fun(a, b); @@ -1591,8 +1590,7 @@ impl<'tcx> GotocCtx<'tcx> { let (ret_type_len, ret_type_subtype) = rust_ret_type.simd_size_and_type(self.tcx); if ret_type_len != n { let err_msg = format!( - "expected return type of length {}, found `{}` with length {}", - n, rust_ret_type, ret_type_len + "expected return type of length {n}, found `{rust_ret_type}` with length {ret_type_len}" ); self.tcx.sess.span_err(span.unwrap(), err_msg); } diff --git a/kani-compiler/src/codegen_cprover_gotoc/codegen/operand.rs b/kani-compiler/src/codegen_cprover_gotoc/codegen/operand.rs index 5e907d63fc4b..5bb66a7dff76 100644 --- a/kani-compiler/src/codegen_cprover_gotoc/codegen/operand.rs +++ b/kani-compiler/src/codegen_cprover_gotoc/codegen/operand.rs @@ -220,7 +220,7 @@ impl<'tcx> GotocCtx<'tcx> { // TODO: Handle cases with other types such as tuples and larger integers. let loc = self.codegen_span_option(span.cloned()); let typ = self.codegen_ty(lit_ty); - let operation_name = format!("Constant slice for type {}", slice_ty); + let operation_name = format!("Constant slice for type {slice_ty}"); return self.codegen_unimplemented_expr( &operation_name, typ, diff --git a/kani-compiler/src/codegen_cprover_gotoc/codegen/place.rs b/kani-compiler/src/codegen_cprover_gotoc/codegen/place.rs index a464ad8c3cb2..97d0c225c963 100644 --- a/kani-compiler/src/codegen_cprover_gotoc/codegen/place.rs +++ b/kani-compiler/src/codegen_cprover_gotoc/codegen/place.rs @@ -173,8 +173,7 @@ impl<'tcx> ProjectedPlace<'tcx> { Self::check_expr_typ_mismatch(&goto_expr, &mir_typ_or_variant, ctx) { let msg = format!( - "Unexpected type mismatch in projection:\n{:?}\nExpr type\n{:?}\nType from MIR\n{:?}", - goto_expr, expr_ty, ty_from_mir + "Unexpected type mismatch in projection:\n{goto_expr:?}\nExpr type\n{expr_ty:?}\nType from MIR\n{ty_from_mir:?}" ); warn!("{}", msg); // TODO: there's an expr type mismatch with the rust 2022-11-20 toolchain diff --git a/kani-compiler/src/codegen_cprover_gotoc/codegen/rvalue.rs b/kani-compiler/src/codegen_cprover_gotoc/codegen/rvalue.rs index e6000860c6a9..4e58b82237cd 100644 --- a/kani-compiler/src/codegen_cprover_gotoc/codegen/rvalue.rs +++ b/kani-compiler/src/codegen_cprover_gotoc/codegen/rvalue.rs @@ -940,8 +940,7 @@ impl<'tcx> GotocCtx<'tcx> { // https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=0f6eef4f6abeb279031444735e73d2e1 assert!( matches!(operand_type.kind(), ty::Never), - "Expected Never, got: {:?}", - operand_type + "Expected Never, got: {operand_type:?}" ); Type::size_t().zero() } else { diff --git a/kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs b/kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs index 50423310cd61..97d851fa511e 100644 --- a/kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs +++ b/kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs @@ -135,8 +135,8 @@ impl<'tcx> GotocCtx<'tcx> { /// This method prints the details of a GotoC type, for debugging purposes. #[allow(unused)] pub(crate) fn debug_print_type_recursively(&self, ty: &Type) -> String { - fn debug_write_type<'tcx>( - ctx: &GotocCtx<'tcx>, + fn debug_write_type( + ctx: &GotocCtx, ty: &Type, out: &mut impl std::fmt::Write, indent: usize, @@ -1782,12 +1782,7 @@ impl<'tcx> GotocCtx<'tcx> { let mut typ = struct_type; while let ty::Adt(adt_def, adt_substs) = typ.kind() { - assert_eq!( - adt_def.variants().len(), - 1, - "Expected a single-variant ADT. Found {:?}", - typ - ); + assert_eq!(adt_def.variants().len(), 1, "Expected a single-variant ADT. Found {typ:?}"); let fields = &adt_def.variants().get(VariantIdx::from_u32(0)).unwrap().fields; let last_field = fields.last().expect("Trait should be the last element."); typ = last_field.ty(self.tcx, adt_substs); diff --git a/kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs b/kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs index a1f95cd1ca2e..34a2296d36e2 100644 --- a/kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs +++ b/kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs @@ -267,8 +267,7 @@ fn check_options(session: &Session) { Some(1) => (), Some(align) => { let err_msg = format!( - "Kani requires the target architecture option `min_global_align` to be 1, but it is {}.", - align + "Kani requires the target architecture option `min_global_align` to be 1, but it is {align}." ); session.err(&err_msg); } @@ -322,7 +321,7 @@ fn check_crate_items(gcx: &GotocCtx) { } /// Prints a report at the end of the compilation. -fn print_report<'tcx>(ctx: &GotocCtx, tcx: TyCtxt<'tcx>) { +fn print_report(ctx: &GotocCtx, tcx: TyCtxt) { // Print all unsupported constructs. if !ctx.unsupported_constructs.is_empty() { // Sort alphabetically. diff --git a/kani-compiler/src/kani_middle/provide.rs b/kani-compiler/src/kani_middle/provide.rs index 7bd7c8e4a62a..990b56639890 100644 --- a/kani-compiler/src/kani_middle/provide.rs +++ b/kani-compiler/src/kani_middle/provide.rs @@ -32,7 +32,7 @@ pub fn provide_extern(providers: &mut ExternProviders) { /// Returns the optimized code for the function associated with `def_id` by /// running rustc's optimization passes followed by Kani-specific passes. -fn run_mir_passes<'tcx, const EXTERN: bool>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &Body<'tcx> { +fn run_mir_passes(tcx: TyCtxt, def_id: DefId) -> &Body { tracing::debug!(?def_id, "Run rustc transformation passes"); let optimized_mir = if EXTERN { rustc_interface::DEFAULT_EXTERN_QUERY_PROVIDERS.optimized_mir diff --git a/kani-compiler/src/kani_middle/reachability.rs b/kani-compiler/src/kani_middle/reachability.rs index 41f4d0f8aa2c..200854a72db5 100644 --- a/kani-compiler/src/kani_middle/reachability.rs +++ b/kani-compiler/src/kani_middle/reachability.rs @@ -443,8 +443,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MonoItemsFnCollector<'a, 'tcx> { } else { assert!( matches!(fn_ty.kind(), TyKind::FnPtr(..)), - "Unexpected type: {:?}", - fn_ty + "Unexpected type: {fn_ty:?}" ); } } @@ -509,7 +508,7 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) -> } /// Scans the allocation type and collect static objects. -fn collect_alloc_items<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId) -> Vec { +fn collect_alloc_items(tcx: TyCtxt, alloc_id: AllocId) -> Vec { trace!(alloc=?tcx.global_alloc(alloc_id), ?alloc_id, "collect_alloc_items"); let mut items = vec![]; match tcx.global_alloc(alloc_id) { diff --git a/kani-compiler/src/kani_middle/stubbing/annotations.rs b/kani-compiler/src/kani_middle/stubbing/annotations.rs index 004b39fbd658..16079efde4c5 100644 --- a/kani-compiler/src/kani_middle/stubbing/annotations.rs +++ b/kani-compiler/src/kani_middle/stubbing/annotations.rs @@ -98,7 +98,7 @@ fn extract_stubbing_pair( if let Some(def_id) = maybe_resolved { tracing::debug!(?def_id, "Resolved {name} to {}", tcx.def_path_str(def_id)); } else { - tcx.sess.span_err(attr.span, format!("unable to resolve function/method: {}", name)); + tcx.sess.span_err(attr.span, format!("unable to resolve function/method: {name}")); } maybe_resolved }; diff --git a/kani-compiler/src/session.rs b/kani-compiler/src/session.rs index 12e5beb87f9b..460cffe364f4 100644 --- a/kani-compiler/src/session.rs +++ b/kani-compiler/src/session.rs @@ -31,8 +31,7 @@ static PANIC_HOOK: LazyLock) + Sync + Send + 's // Print the Kani message eprintln!("Kani unexpectedly panicked during compilation."); eprintln!( - "If you are seeing this message, please file an issue here: {}", - BUG_REPORT_URL + "If you are seeing this message, please file an issue here: {BUG_REPORT_URL}" ); })); hook diff --git a/kani-driver/src/args.rs b/kani-driver/src/args.rs index 2f1d191a4c8c..65b4945b86cc 100644 --- a/kani-driver/src/args.rs +++ b/kani-driver/src/args.rs @@ -430,8 +430,7 @@ impl KaniArgs { println!( "Using concrete playback with --randomize-layout.\n\ The produced tests will have to be played with the same rustc arguments:\n\ - -Z randomize-layout{}", - random_seed + -Z randomize-layout{random_seed}" ); } diff --git a/kani-driver/src/assess/mod.rs b/kani-driver/src/assess/mod.rs index 2a444cd57937..d135a998b7a9 100644 --- a/kani-driver/src/assess/mod.rs +++ b/kani-driver/src/assess/mod.rs @@ -112,7 +112,7 @@ fn reconstruct_metadata_structure( } if !search.is_empty() { let search_names: Vec<_> = search.into_iter().map(|x| x.crate_name).collect(); - println!("Found remaining (unused) metadata after reconstruction: {:?}", search_names); + println!("Found remaining (unused) metadata after reconstruction: {search_names:?}"); } Ok(results) } diff --git a/kani-driver/src/call_cargo.rs b/kani-driver/src/call_cargo.rs index f40c7f55ad72..26f67b7f8973 100644 --- a/kani-driver/src/call_cargo.rs +++ b/kani-driver/src/call_cargo.rs @@ -156,7 +156,7 @@ fn glob(path: &Path) -> Result> { /// - I.e.: Do whatever cargo does when there's no `default_members`. /// - This is because `default_members` is not available in cargo metadata. /// See . -fn packages_to_verify<'a, 'b>(args: &'a KaniArgs, metadata: &'b Metadata) -> Vec<&'b Package> { +fn packages_to_verify<'b>(args: &KaniArgs, metadata: &'b Metadata) -> Vec<&'b Package> { debug!(package_selection=?args.package, workspace=args.workspace, "packages_to_verify args"); let packages = if !args.package.is_empty() { args.package diff --git a/kani-driver/src/cbmc_property_renderer.rs b/kani-driver/src/cbmc_property_renderer.rs index b1e64cf9c5d9..8a5e8f16827a 100644 --- a/kani-driver/src/cbmc_property_renderer.rs +++ b/kani-driver/src/cbmc_property_renderer.rs @@ -324,7 +324,7 @@ pub fn format_result(properties: &Vec, show_checks: bool) -> String { let number_properties = properties.len() - number_cover_properties; - let summary = format!("\n ** {number_checks_failed} of {} failed", number_properties); + let summary = format!("\n ** {number_checks_failed} of {number_properties} failed"); result_str.push_str(&summary); let mut other_status = Vec::::new(); @@ -346,8 +346,7 @@ pub fn format_result(properties: &Vec, show_checks: bool) -> String { if number_cover_properties > 0 { // Print a summary line for cover properties let summary = format!( - "\n ** {number_covers_satisfied} of {} cover properties satisfied", - number_cover_properties + "\n ** {number_covers_satisfied} of {number_cover_properties} cover properties satisfied" ); result_str.push_str(&summary); let mut other_status = Vec::::new(); @@ -420,8 +419,7 @@ fn build_failure_message(description: String, trace: &Option>) -> let failure_function = failure_source.function.unwrap(); let failure_line = failure_source.line.unwrap(); return format!( - "Failed Checks: {}\n File: \"{}\", line {}, in {}\n", - description, failure_file, failure_line, failure_function + "Failed Checks: {description}\n File: \"{failure_file}\", line {failure_line}, in {failure_function}\n" ); } backup_failure_message @@ -576,8 +574,7 @@ fn update_properties_with_reach_status( let description = &prop.description; assert!( prop.status == CheckStatus::Success, - "** ERROR: Expecting the unreachable property \"{}\" to have a status of \"SUCCESS\"", - description + "** ERROR: Expecting the unreachable property \"{description}\" to have a status of \"SUCCESS\"" ); prop.status = CheckStatus::Unreachable } diff --git a/kani-driver/src/concrete_playback.rs b/kani-driver/src/concrete_playback.rs index 5e675e10f223..ae1fad1195f7 100644 --- a/kani-driver/src/concrete_playback.rs +++ b/kani-driver/src/concrete_playback.rs @@ -149,8 +149,7 @@ impl KaniSession { })?; let src_file_name_as_str = src_file_name_as_osstr.to_str().with_context(|| { format!( - "Couldn't convert source code file name `{:?}` from OsStr to str", - src_file_name_as_osstr + "Couldn't convert source code file name `{src_file_name_as_osstr:?}` from OsStr to str" ) })?; @@ -255,8 +254,7 @@ fn format_unit_test( "// This test has to be run with rustc option: -Z randomize-layout\n ".to_string() } Some(Some(seed)) => format!( - "// This test has to be run with rust options: -Z randomize-layout -Z layout-seed={}\n ", - seed, + "// This test has to be run with rust options: -Z randomize-layout -Z layout-seed={seed}\n ", ), }; diff --git a/kani-driver/src/harness_runner.rs b/kani-driver/src/harness_runner.rs index ac7595b3b0b0..9d9f8cb49fec 100644 --- a/kani-driver/src/harness_runner.rs +++ b/kani-driver/src/harness_runner.rs @@ -133,8 +133,7 @@ impl KaniSession { if total > 0 { println!( - "Complete - {} successfully verified harnesses, {} failures, {} total.", - succeeding, failing, total + "Complete - {succeeding} successfully verified harnesses, {failing} failures, {total} total." ); } else { // TODO: This could use a better error message, possibly with links to Kani documentation. diff --git a/library/kani_macros/src/derive.rs b/library/kani_macros/src/derive.rs index 2a17e16d8b09..7e3dee390330 100644 --- a/library/kani_macros/src/derive.rs +++ b/library/kani_macros/src/derive.rs @@ -138,8 +138,7 @@ fn init_symbolic_item(ident: &Ident, fields: &Fields) -> TokenStream { fn fn_any_enum(ident: &Ident, data: &DataEnum) -> TokenStream { if data.variants.is_empty() { let msg = format!( - "Cannot create symbolic enum `{}`. Enums with zero-variants cannot be instantiated", - ident + "Cannot create symbolic enum `{ident}`. Enums with zero-variants cannot be instantiated" ); quote! { panic!(#msg) diff --git a/src/lib.rs b/src/lib.rs index a8557a819f6b..6d398e624b17 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -206,7 +206,7 @@ mod tests { #[test] fn check_arg_parsing() { fn trial(args: &[&str]) -> ArgsResult { - parse_args(args.into_iter().map(OsString::from).collect()) + parse_args(args.iter().map(OsString::from).collect()) } { let e = ArgsResult::Default; diff --git a/tools/bookrunner/librustdoc/doctest.rs b/tools/bookrunner/librustdoc/doctest.rs index 15062c975fa8..c6c2166abf98 100644 --- a/tools/bookrunner/librustdoc/doctest.rs +++ b/tools/bookrunner/librustdoc/doctest.rs @@ -231,8 +231,7 @@ pub fn make_test( let (main_pre, main_post) = if returns_result { ( format!( - "fn main() {{ {}fn {}() -> Result<(), impl core::fmt::Debug> {{\n", - inner_attr, inner_fn_name + "fn main() {{ {inner_attr}fn {inner_fn_name}() -> Result<(), impl core::fmt::Debug> {{\n" ), format!("\n}} {inner_fn_name}().unwrap() }}"), ) diff --git a/tools/build-kani/src/sysroot.rs b/tools/build-kani/src/sysroot.rs index 84e9a95c634b..ce34f6185358 100644 --- a/tools/build-kani/src/sysroot.rs +++ b/tools/build-kani/src/sysroot.rs @@ -229,7 +229,7 @@ pub fn build_lib_legacy() { // Create sysroot folder. let legacy_lib = kani_sysroot_legacy_lib(); legacy_lib.exists().then(|| fs::remove_dir_all(&legacy_lib)); - fs::create_dir_all(&legacy_lib).expect(&format!("Failed to create {:?}", legacy_lib)); + fs::create_dir_all(&legacy_lib).expect(&format!("Failed to create {legacy_lib:?}")); // Copy Kani libraries to inside the legacy-lib folder. copy_libs(&artifacts, &legacy_lib, &is_kani_lib); diff --git a/tools/compiletest/src/json.rs b/tools/compiletest/src/json.rs index a7997fefb368..299d81578eb3 100644 --- a/tools/compiletest/src/json.rs +++ b/tools/compiletest/src/json.rs @@ -78,8 +78,7 @@ pub fn extract_rendered(output: &str) -> String { None } else { print!( - "failed to decode compiler output as json: line: {}\noutput: {}", - line, output + "failed to decode compiler output as json: line: {line}\noutput: {output}" ); panic!() }