Skip to content

Commit fece7ee

Browse files
authored
Address clippy warnings (rust-lang#2807)
Versions of clippy that come with newer toolchains report a large number of needless_borrows_for_generic_args. We can address these now so that we don't have to make these changes as part of a toolchain update.
1 parent fb08f3e commit fece7ee

File tree

24 files changed

+54
-52
lines changed

24 files changed

+54
-52
lines changed

cprover_bindings/src/goto_program/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ impl BuiltinFn {
329329
/// Converters: build symbols and expressions from Builtins
330330
impl BuiltinFn {
331331
pub fn as_symbol(&self) -> Symbol {
332-
Symbol::builtin_function(&self.to_string(), self.param_types(), self.return_type())
332+
Symbol::builtin_function(self.to_string(), self.param_types(), self.return_type())
333333
}
334334

335335
pub fn as_expr(&self) -> Expr {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ impl<'tcx> GotocCtx<'tcx> {
561561
}
562562

563563
let mem_place =
564-
self.symbol_table.lookup(&self.alloc_map.get(&alloc).unwrap()).unwrap().to_expr();
564+
self.symbol_table.lookup(self.alloc_map.get(&alloc).unwrap()).unwrap().to_expr();
565565
mem_place.address_of()
566566
}
567567

@@ -579,16 +579,16 @@ impl<'tcx> GotocCtx<'tcx> {
579579
// initializers. For example, for a boolean static variable, the variable will have type
580580
// CBool and the initializer will be a single byte (a one-character array) representing the
581581
// bit pattern for the boolean value.
582-
let alloc_typ_ref = self.ensure_struct(&struct_name, &struct_name, |ctx, _| {
582+
let alloc_typ_ref = self.ensure_struct(struct_name, struct_name, |ctx, _| {
583583
ctx.codegen_allocation_data(alloc)
584584
.iter()
585585
.enumerate()
586586
.map(|(i, d)| match d {
587587
AllocData::Bytes(bytes) => DatatypeComponent::field(
588-
&i.to_string(),
588+
i.to_string(),
589589
Type::unsigned_int(8).array_of(bytes.len()),
590590
),
591-
AllocData::Expr(e) => DatatypeComponent::field(&i.to_string(), e.typ().clone()),
591+
AllocData::Expr(e) => DatatypeComponent::field(i.to_string(), e.typ().clone()),
592592
})
593593
.collect()
594594
});

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,10 @@ impl<'tcx> GotocCtx<'tcx> {
268268
| ty::Param(_)
269269
| ty::Infer(_)
270270
| ty::Error(_) => unreachable!("type {parent_ty:?} does not have a field"),
271-
ty::Tuple(_) => Ok(parent_expr
272-
.member(&Self::tuple_fld_name(field.index()), &self.symbol_table)),
271+
ty::Tuple(_) => {
272+
Ok(parent_expr
273+
.member(Self::tuple_fld_name(field.index()), &self.symbol_table))
274+
}
273275
ty::Adt(def, _) if def.repr().simd() => Ok(self.codegen_simd_field(
274276
parent_expr,
275277
*field,
@@ -278,10 +280,10 @@ impl<'tcx> GotocCtx<'tcx> {
278280
// if we fall here, then we are handling either a struct or a union
279281
ty::Adt(def, _) => {
280282
let field = &def.variants().raw[0].fields[*field];
281-
Ok(parent_expr.member(&field.name.to_string(), &self.symbol_table))
283+
Ok(parent_expr.member(field.name.to_string(), &self.symbol_table))
282284
}
283285
ty::Closure(..) => {
284-
Ok(parent_expr.member(&field.index().to_string(), &self.symbol_table))
286+
Ok(parent_expr.member(field.index().to_string(), &self.symbol_table))
285287
}
286288
ty::Generator(..) => {
287289
let field_name = self.generator_field_name(field.as_usize());
@@ -299,7 +301,7 @@ impl<'tcx> GotocCtx<'tcx> {
299301
// if we fall here, then we are handling an enum
300302
TypeOrVariant::Variant(parent_var) => {
301303
let field = &parent_var.fields[*field];
302-
Ok(parent_expr.member(&field.name.to_string(), &self.symbol_table))
304+
Ok(parent_expr.member(field.name.to_string(), &self.symbol_table))
303305
}
304306
TypeOrVariant::GeneratorVariant(_var_idx) => {
305307
let field_name = self.generator_field_name(field.index());

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ impl<'tcx> GotocCtx<'tcx> {
864864
// We need to pad to the next offset
865865
let padding_size = next_offset - current_offset;
866866
let name = format!("$pad{idx}");
867-
Some(DatatypeComponent::padding(&name, padding_size.bits()))
867+
Some(DatatypeComponent::padding(name, padding_size.bits()))
868868
} else {
869869
None
870870
}
@@ -1378,7 +1378,7 @@ impl<'tcx> GotocCtx<'tcx> {
13781378
.iter()
13791379
.map(|f| {
13801380
DatatypeComponent::field(
1381-
&f.name.to_string(),
1381+
f.name.to_string(),
13821382
ctx.codegen_ty(f.ty(ctx.tcx, subst)),
13831383
)
13841384
})
@@ -1641,7 +1641,7 @@ impl<'tcx> GotocCtx<'tcx> {
16411641
None
16421642
} else {
16431643
Some(DatatypeComponent::field(
1644-
&case.name.to_string(),
1644+
case.name.to_string(),
16451645
self.codegen_enum_case_struct(
16461646
name,
16471647
pretty_name,

kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl CodegenBackend for GotocCodegenBackend {
271271
if let MonoItem::Fn(instance) = test_fn { instance } else { continue };
272272
let metadata = gen_test_metadata(tcx, *test_desc, *instance, &base_filename);
273273
let test_model_path = &metadata.goto_file.as_ref().unwrap();
274-
std::fs::copy(&model_path, &test_model_path).expect(&format!(
274+
std::fs::copy(&model_path, test_model_path).expect(&format!(
275275
"Failed to copy {} to {}",
276276
model_path.display(),
277277
test_model_path.display()

kani-compiler/src/kani_compiler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ impl KaniCompiler {
352352
/// Write the metadata to a file
353353
fn store_metadata(&self, metadata: &KaniMetadata, filename: &Path) {
354354
debug!(?filename, "write_metadata");
355-
let out_file = File::create(&filename).unwrap();
355+
let out_file = File::create(filename).unwrap();
356356
let writer = BufWriter::new(out_file);
357357
if self.queries.lock().unwrap().args().output_pretty_json {
358358
serde_json::to_writer_pretty(writer, &metadata).unwrap();

kani-compiler/src/kani_middle/reachability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ mod debug {
725725
debug!(?target, "dump_dot");
726726
let outputs = tcx.output_filenames(());
727727
let path = outputs.output_path(OutputType::Metadata).with_extension("dot");
728-
let out_file = File::create(&path)?;
728+
let out_file = File::create(path)?;
729729
let mut writer = BufWriter::new(out_file);
730730
writeln!(writer, "digraph ReachabilityGraph {{")?;
731731
if target.is_empty() {

kani-driver/src/args/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ fn check_no_cargo_opt(is_set: bool, name: &str) -> Result<(), Error> {
427427
if is_set {
428428
Err(Error::raw(
429429
ErrorKind::UnknownArgument,
430-
&format!("argument `{}` cannot be used with standalone Kani.", name),
430+
format!("argument `{}` cannot be used with standalone Kani.", name),
431431
))
432432
} else {
433433
Ok(())
@@ -453,7 +453,7 @@ impl ValidateArgs for StandaloneArgs {
453453
if !input.is_file() {
454454
return Err(Error::raw(
455455
ErrorKind::InvalidValue,
456-
&format!(
456+
format!(
457457
"Invalid argument: Input invalid. `{}` is not a regular file.",
458458
input.display()
459459
),
@@ -583,7 +583,7 @@ impl ValidateArgs for VerificationArgs {
583583
if out_dir.exists() && !out_dir.is_dir() {
584584
return Err(Error::raw(
585585
ErrorKind::InvalidValue,
586-
&format!(
586+
format!(
587587
"Invalid argument: `--target-dir` argument `{}` is not a directory",
588588
out_dir.display()
589589
),

kani-driver/src/args/playback_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl ValidateArgs for KaniPlaybackArgs {
7474
if !self.input.is_file() {
7575
return Err(Error::raw(
7676
ErrorKind::InvalidValue,
77-
&format!(
77+
format!(
7878
"Invalid argument: Input invalid. `{}` is not a regular file.",
7979
self.input.display()
8080
),

kani-driver/src/assess/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub struct SessionError {
8888
/// If given the argument to so do, write the assess metadata to the target file.
8989
pub(crate) fn write_metadata(args: &AssessArgs, metadata: AssessMetadata) -> Result<()> {
9090
if let Some(path) = &args.emit_metadata {
91-
let out_file = File::create(&path)?;
91+
let out_file = File::create(path)?;
9292
let writer = BufWriter::new(out_file);
9393
// use pretty for now to keep things readable and debuggable, but this should change eventually
9494
serde_json::to_writer_pretty(writer, &metadata)?;

0 commit comments

Comments
 (0)