Skip to content

Commit 5a431d0

Browse files
authored
Clippy fixes for upcoming rust toolchain update (rust-lang#2061)
1 parent a6c21c4 commit 5a431d0

File tree

27 files changed

+57
-134
lines changed

27 files changed

+57
-134
lines changed

cprover_bindings/src/goto_program/expr.rs

Lines changed: 16 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,7 @@ impl Expr {
433433
assert_eq!(size as usize, elems.len());
434434
assert!(
435435
elems.iter().all(|x| x.typ == *value_typ),
436-
"Array type and value types don't match: \n{:?}\n{:?}",
437-
typ,
438-
elems
436+
"Array type and value types don't match: \n{typ:?}\n{elems:?}"
439437
);
440438
} else {
441439
unreachable!("Can't make an array_val with non-array target type {:?}", typ);
@@ -448,9 +446,7 @@ impl Expr {
448446
assert_eq!(size as usize, elems.len());
449447
assert!(
450448
elems.iter().all(|x| x.typ == *value_typ),
451-
"Vector type and value types don't match: \n{:?}\n{:?}",
452-
typ,
453-
elems
449+
"Vector type and value types don't match: \n{typ:?}\n{elems:?}"
454450
);
455451
} else {
456452
unreachable!("Can't make a vector_val with non-vector target type {:?}", typ);
@@ -642,9 +638,7 @@ impl Expr {
642638
pub fn call(self, arguments: Vec<Expr>) -> Self {
643639
assert!(
644640
Expr::typecheck_call(&self, &arguments),
645-
"Function call does not type check:\nfunc: {:?}\nargs: {:?}",
646-
self,
647-
arguments
641+
"Function call does not type check:\nfunc: {self:?}\nargs: {arguments:?}"
648642
);
649643
let typ = self.typ().return_type().unwrap().clone();
650644
expr!(FunctionCall { function: self, arguments }, typ)
@@ -658,9 +652,7 @@ impl Expr {
658652
let field: InternedString = field.into();
659653
assert!(
660654
self.typ.is_struct_tag() || self.typ.is_union_tag(),
661-
"Can't apply .member operation to\n\t{:?}\n\t{}",
662-
self,
663-
field,
655+
"Can't apply .member operation to\n\t{self:?}\n\t{field}",
664656
);
665657
if let Some(ty) = self.typ.lookup_field_type(field, symbol_table) {
666658
expr!(Member { lhs: self, field }, ty)
@@ -701,10 +693,7 @@ impl Expr {
701693
// Check that each formal field has an value
702694
assert!(
703695
fields.iter().zip(values.iter()).all(|(f, v)| f.typ() == *v.typ()),
704-
"Error in struct_expr; value type does not match field type.\n\t{:?}\n\t{:?}\n\t{:?}",
705-
typ,
706-
fields,
707-
values
696+
"Error in struct_expr; value type does not match field type.\n\t{typ:?}\n\t{fields:?}\n\t{values:?}"
708697
);
709698
expr!(Struct { values }, typ)
710699
}
@@ -720,18 +709,14 @@ impl Expr {
720709
) -> Self {
721710
assert!(
722711
typ.is_struct_tag(),
723-
"Error in struct_expr; must be given a struct_tag.\n\t{:?}\n\t{:?}",
724-
typ,
725-
components
712+
"Error in struct_expr; must be given a struct_tag.\n\t{typ:?}\n\t{components:?}"
726713
);
727714
let fields = typ.lookup_components(symbol_table).unwrap();
728715
let non_padding_fields: Vec<_> = fields.iter().filter(|x| !x.is_padding()).collect();
729716
assert_eq!(
730717
non_padding_fields.len(),
731718
components.len(),
732-
"Error in struct_expr; mismatch in number of fields and components.\n\t{:?}\n\t{:?}",
733-
typ,
734-
components
719+
"Error in struct_expr; mismatch in number of fields and components.\n\t{typ:?}\n\t{components:?}"
735720
);
736721

737722
// Check that each formal field has an value
@@ -790,28 +775,21 @@ impl Expr {
790775
) -> Self {
791776
assert!(
792777
typ.is_struct_tag(),
793-
"Error in struct_expr; must be given struct_tag.\n\t{:?}\n\t{:?}",
794-
typ,
795-
non_padding_values
778+
"Error in struct_expr; must be given struct_tag.\n\t{typ:?}\n\t{non_padding_values:?}"
796779
);
797780
let fields = typ.lookup_components(symbol_table).unwrap();
798781
let non_padding_fields: Vec<_> = fields.iter().filter(|x| !x.is_padding()).collect();
799782
assert_eq!(
800783
non_padding_fields.len(),
801784
non_padding_values.len(),
802-
"Error in struct_expr; mismatch in number of fields and values.\n\t{:?}\n\t{:?}",
803-
typ,
804-
non_padding_values
785+
"Error in struct_expr; mismatch in number of fields and values.\n\t{typ:?}\n\t{non_padding_values:?}"
805786
);
806787
assert!(
807788
non_padding_fields
808789
.iter()
809790
.zip(non_padding_values.iter())
810791
.all(|(f, v)| f.field_typ().unwrap() == v.typ()),
811-
"Error in struct_expr; value type does not match field type.\n\t{:?}\n\t{:?}\n\t{:?}",
812-
typ,
813-
non_padding_fields,
814-
non_padding_values
792+
"Error in struct_expr; value type does not match field type.\n\t{typ:?}\n\t{non_padding_fields:?}\n\t{non_padding_values:?}"
815793
);
816794

817795
let values = fields
@@ -834,25 +812,18 @@ impl Expr {
834812
) -> Self {
835813
assert!(
836814
typ.is_struct_tag() || typ.is_struct(),
837-
"Error in struct_expr; must be given struct.\n\t{:?}\n\t{:?}",
838-
typ,
839-
values
815+
"Error in struct_expr; must be given struct.\n\t{typ:?}\n\t{values:?}"
840816
);
841817
let typ = typ.aggr_tag().unwrap();
842818
let fields = typ.lookup_components(symbol_table).unwrap();
843819
assert_eq!(
844820
fields.len(),
845821
values.len(),
846-
"Error in struct_expr; mismatch in number of padded fields and padded values.\n\t{:?}\n\t{:?}",
847-
typ,
848-
values
822+
"Error in struct_expr; mismatch in number of padded fields and padded values.\n\t{typ:?}\n\t{values:?}"
849823
);
850824
assert!(
851825
fields.iter().zip(values.iter()).all(|(f, v)| &f.typ() == v.typ()),
852-
"Error in struct_expr; value type does not match field type.\n\t{:?}\n\t{:?}\n\t{:?}",
853-
typ,
854-
fields,
855-
values
826+
"Error in struct_expr; value type does not match field type.\n\t{typ:?}\n\t{fields:?}\n\t{values:?}"
856827
);
857828

858829
Expr::struct_expr_with_explicit_padding(typ, fields, values)
@@ -1028,10 +999,7 @@ impl Expr {
1028999
pub fn binop(self, op: BinaryOperator, rhs: Expr) -> Expr {
10291000
assert!(
10301001
Expr::typecheck_binop_args(op, &self, &rhs),
1031-
"BinaryOperation Expression does not typecheck {:?} {:?} {:?}",
1032-
op,
1033-
self,
1034-
rhs
1002+
"BinaryOperation Expression does not typecheck {op:?} {self:?} {rhs:?}"
10351003
);
10361004
expr!(BinOp { op, lhs: self, rhs }, Expr::binop_return_type(op, &self, &rhs))
10371005
}
@@ -1041,10 +1009,7 @@ impl Expr {
10411009
pub fn vector_cmp(self, op: BinaryOperator, rhs: Expr, ret_typ: Type) -> Expr {
10421010
assert!(
10431011
Expr::typecheck_vector_cmp_expr(&self, &rhs, &ret_typ),
1044-
"vector comparison expression does not typecheck {:?} {:?} {:?}",
1045-
self,
1046-
rhs,
1047-
ret_typ,
1012+
"vector comparison expression does not typecheck {self:?} {rhs:?} {ret_typ:?}",
10481013
);
10491014
expr!(BinOp { op, lhs: self, rhs }, ret_typ)
10501015
}
@@ -1483,9 +1448,7 @@ impl Expr {
14831448
pub fn reinterpret_cast(self, t: Type) -> Expr {
14841449
assert!(
14851450
self.can_take_address_of(),
1486-
"Can't take address of {:?} when coercing to {:?}",
1487-
self,
1488-
t
1451+
"Can't take address of {self:?} when coercing to {t:?}"
14891452
);
14901453
self.address_of().cast_to(t.to_pointer()).dereference()
14911454
}

cprover_bindings/src/goto_program/stmt.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@ impl Stmt {
264264
) -> Self {
265265
assert!(
266266
Expr::typecheck_call(&function, &arguments),
267-
"Function call does not type check:\nfunc: {:?}\nargs: {:?}",
268-
function,
269-
arguments
267+
"Function call does not type check:\nfunc: {function:?}\nargs: {arguments:?}"
270268
);
271269
if let Some(lhs) = &lhs {
272270
assert_eq!(lhs.typ(), function.typ().return_type().unwrap())

cprover_bindings/src/goto_program/symbol.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ impl Symbol {
7474
// See https://github.com/model-checking/kani/issues/1361#issuecomment-1181499683
7575
assert!(
7676
name.to_string().ends_with(&base_name.map_or(String::new(), |s| s.to_string())),
77-
"Symbol's base_name must be the suffix of its name.\nName: {:?}\nBase name: {:?}",
78-
name,
79-
base_name
77+
"Symbol's base_name must be the suffix of its name.\nName: {name:?}\nBase name: {base_name:?}"
8078
);
8179
Symbol {
8280
name,

cprover_bindings/src/goto_program/typ.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,7 @@ impl DatatypeComponent {
191191
let name = name.into();
192192
assert!(
193193
Self::typecheck_datatype_field(&typ),
194-
"Illegal field.\n\tName: {}\n\tType: {:?}",
195-
name,
196-
typ
194+
"Illegal field.\n\tName: {name}\n\tType: {typ:?}"
197195
);
198196
Field { name, typ }
199197
}
@@ -942,13 +940,7 @@ impl Type {
942940
identifier: Option<InternedString>,
943941
base_name: Option<InternedString>,
944942
) -> Parameter {
945-
assert!(
946-
self.can_be_lvalue(),
947-
"Expected lvalue from {:?} {:?} {:?}",
948-
self,
949-
identifier,
950-
base_name
951-
);
943+
assert!(self.can_be_lvalue(), "Expected lvalue from {self:?} {identifier:?} {base_name:?}");
952944
Parameter { identifier, base_name, typ: self }
953945
}
954946

@@ -1133,13 +1125,11 @@ impl Type {
11331125
) -> Self {
11341126
assert!(
11351127
Type::components_are_unique(&components),
1136-
"Components contain duplicates: {:?}",
1137-
components
1128+
"Components contain duplicates: {components:?}"
11381129
);
11391130
assert!(
11401131
Type::components_in_valid_order_for_struct(&components),
1141-
"Components are not in valid order for struct: {:?}",
1142-
components
1132+
"Components are not in valid order for struct: {components:?}"
11431133
);
11441134

11451135
let tag = tag.into();
@@ -1168,13 +1158,11 @@ impl Type {
11681158
let tag = tag.into();
11691159
assert!(
11701160
Type::components_are_unique(&components),
1171-
"Components contain duplicates: {:?}",
1172-
components
1161+
"Components contain duplicates: {components:?}"
11731162
);
11741163
assert!(
11751164
Type::components_are_not_flexible_array(&components),
1176-
"Unions cannot contain flexible arrays: {:?}",
1177-
components
1165+
"Unions cannot contain flexible arrays: {components:?}"
11781166
);
11791167
Union { tag, components }
11801168
}

kani-compiler/src/codegen_cprover_gotoc/archive.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ impl<'a> ArchiveBuilder<'a> {
4545
BuilderKind::Gnu(ar::GnuBuilder::new(
4646
File::create(&output).unwrap_or_else(|err| {
4747
sess.fatal(&format!(
48-
"error opening destination during archive building: {}",
49-
err
48+
"error opening destination during archive building: {err}"
5049
));
5150
}),
5251
self.entries.iter().map(|(name, _)| name.clone()).collect(),

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ impl<'tcx> GotocCtx<'tcx> {
297297
"https://github.com/model-checking/kani/issues/new?template=bug_report.md";
298298

299299
let assert_msg = format!(
300-
"Kani-internal sanity check: {}. Please report failures:\n{}",
301-
message, BUG_REPORT_URL
300+
"Kani-internal sanity check: {message}. Please report failures:\n{BUG_REPORT_URL}"
302301
);
303302

304303
self.codegen_assert_assume(cond, PropertyClass::SanityCheck, &assert_msg, loc)

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,8 +1499,7 @@ impl<'tcx> GotocCtx<'tcx> {
14991499
if !ret_typ.base_type().unwrap().is_integer() {
15001500
let (_, rust_base_type) = rust_ret_type.simd_size_and_type(self.tcx);
15011501
let err_msg = format!(
1502-
"expected return type with integer elements, found `{}` with non-integer `{}`",
1503-
rust_ret_type, rust_base_type,
1502+
"expected return type with integer elements, found `{rust_ret_type}` with non-integer `{rust_base_type}`",
15041503
);
15051504
self.tcx.sess.span_err(span.unwrap(), err_msg);
15061505
}
@@ -1541,7 +1540,7 @@ impl<'tcx> GotocCtx<'tcx> {
15411540
let check_stmt = self.codegen_assert_assume(
15421541
check.not(),
15431542
PropertyClass::ArithmeticOverflow,
1544-
format!("attempt to compute {} which would overflow", intrinsic).as_str(),
1543+
format!("attempt to compute {intrinsic} which would overflow").as_str(),
15451544
loc,
15461545
);
15471546
let res = op_fun(a, b);
@@ -1591,8 +1590,7 @@ impl<'tcx> GotocCtx<'tcx> {
15911590
let (ret_type_len, ret_type_subtype) = rust_ret_type.simd_size_and_type(self.tcx);
15921591
if ret_type_len != n {
15931592
let err_msg = format!(
1594-
"expected return type of length {}, found `{}` with length {}",
1595-
n, rust_ret_type, ret_type_len
1593+
"expected return type of length {n}, found `{rust_ret_type}` with length {ret_type_len}"
15961594
);
15971595
self.tcx.sess.span_err(span.unwrap(), err_msg);
15981596
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl<'tcx> GotocCtx<'tcx> {
220220
// TODO: Handle cases with other types such as tuples and larger integers.
221221
let loc = self.codegen_span_option(span.cloned());
222222
let typ = self.codegen_ty(lit_ty);
223-
let operation_name = format!("Constant slice for type {}", slice_ty);
223+
let operation_name = format!("Constant slice for type {slice_ty}");
224224
return self.codegen_unimplemented_expr(
225225
&operation_name,
226226
typ,

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ impl<'tcx> ProjectedPlace<'tcx> {
173173
Self::check_expr_typ_mismatch(&goto_expr, &mir_typ_or_variant, ctx)
174174
{
175175
let msg = format!(
176-
"Unexpected type mismatch in projection:\n{:?}\nExpr type\n{:?}\nType from MIR\n{:?}",
177-
goto_expr, expr_ty, ty_from_mir
176+
"Unexpected type mismatch in projection:\n{goto_expr:?}\nExpr type\n{expr_ty:?}\nType from MIR\n{ty_from_mir:?}"
178177
);
179178
warn!("{}", msg);
180179
// TODO: there's an expr type mismatch with the rust 2022-11-20 toolchain

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,8 +940,7 @@ impl<'tcx> GotocCtx<'tcx> {
940940
// https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=0f6eef4f6abeb279031444735e73d2e1
941941
assert!(
942942
matches!(operand_type.kind(), ty::Never),
943-
"Expected Never, got: {:?}",
944-
operand_type
943+
"Expected Never, got: {operand_type:?}"
945944
);
946945
Type::size_t().zero()
947946
} else {

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ impl<'tcx> GotocCtx<'tcx> {
135135
/// This method prints the details of a GotoC type, for debugging purposes.
136136
#[allow(unused)]
137137
pub(crate) fn debug_print_type_recursively(&self, ty: &Type) -> String {
138-
fn debug_write_type<'tcx>(
139-
ctx: &GotocCtx<'tcx>,
138+
fn debug_write_type(
139+
ctx: &GotocCtx,
140140
ty: &Type,
141141
out: &mut impl std::fmt::Write,
142142
indent: usize,
@@ -1782,12 +1782,7 @@ impl<'tcx> GotocCtx<'tcx> {
17821782

17831783
let mut typ = struct_type;
17841784
while let ty::Adt(adt_def, adt_substs) = typ.kind() {
1785-
assert_eq!(
1786-
adt_def.variants().len(),
1787-
1,
1788-
"Expected a single-variant ADT. Found {:?}",
1789-
typ
1790-
);
1785+
assert_eq!(adt_def.variants().len(), 1, "Expected a single-variant ADT. Found {typ:?}");
17911786
let fields = &adt_def.variants().get(VariantIdx::from_u32(0)).unwrap().fields;
17921787
let last_field = fields.last().expect("Trait should be the last element.");
17931788
typ = last_field.ty(self.tcx, adt_substs);

kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,7 @@ fn check_options(session: &Session) {
267267
Some(1) => (),
268268
Some(align) => {
269269
let err_msg = format!(
270-
"Kani requires the target architecture option `min_global_align` to be 1, but it is {}.",
271-
align
270+
"Kani requires the target architecture option `min_global_align` to be 1, but it is {align}."
272271
);
273272
session.err(&err_msg);
274273
}
@@ -322,7 +321,7 @@ fn check_crate_items(gcx: &GotocCtx) {
322321
}
323322

324323
/// Prints a report at the end of the compilation.
325-
fn print_report<'tcx>(ctx: &GotocCtx, tcx: TyCtxt<'tcx>) {
324+
fn print_report(ctx: &GotocCtx, tcx: TyCtxt) {
326325
// Print all unsupported constructs.
327326
if !ctx.unsupported_constructs.is_empty() {
328327
// Sort alphabetically.

kani-compiler/src/kani_middle/provide.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn provide_extern(providers: &mut ExternProviders) {
3232

3333
/// Returns the optimized code for the function associated with `def_id` by
3434
/// running rustc's optimization passes followed by Kani-specific passes.
35-
fn run_mir_passes<'tcx, const EXTERN: bool>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &Body<'tcx> {
35+
fn run_mir_passes<const EXTERN: bool>(tcx: TyCtxt, def_id: DefId) -> &Body {
3636
tracing::debug!(?def_id, "Run rustc transformation passes");
3737
let optimized_mir = if EXTERN {
3838
rustc_interface::DEFAULT_EXTERN_QUERY_PROVIDERS.optimized_mir

0 commit comments

Comments
 (0)