From 354f2417b36f924e9da50870fa6f437100f7400a Mon Sep 17 00:00:00 2001 From: arty Date: Wed, 8 May 2024 08:59:32 -0700 Subject: [PATCH] new clippy traffic --- src/classic/clvm_tools/cmds.rs | 10 +++++----- src/classic/clvm_tools/stages/stage_2/optimize.rs | 2 +- src/classic/platform/argparse.rs | 5 +---- src/compiler/codegen.rs | 6 ++++-- src/compiler/compiler.rs | 2 +- src/compiler/comptypes.rs | 2 +- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/classic/clvm_tools/cmds.rs b/src/classic/clvm_tools/cmds.rs index 9bf9771e3..21a2dcc5d 100644 --- a/src/classic/clvm_tools/cmds.rs +++ b/src/classic/clvm_tools/cmds.rs @@ -584,7 +584,7 @@ pub fn cldb(args: &[String]) { } if let Some(ArgumentValue::ArgString(file, path_or_code)) = parsed_args.get("path_or_code") { - input_file = file.clone(); + input_file.clone_from(file); input_program = path_or_code.to_string(); } @@ -1117,7 +1117,7 @@ pub fn launch_tool(stdout: &mut Stream, args: &[String], tool_name: &str, defaul let mut input_program = "()".to_string(); if let Some(ArgumentValue::ArgString(file, path_or_code)) = parsed_args.get("path_or_code") { - input_file = file.clone(); + input_file.clone_from(file); input_program = path_or_code.to_string(); } @@ -1179,7 +1179,7 @@ pub fn launch_tool(stdout: &mut Stream, args: &[String], tool_name: &str, defaul } if let Some(ArgumentValue::ArgString(file, path_or_code)) = parsed_args.get("env") { - input_file = file.clone(); + input_file.clone_from(file); input_args = path_or_code.to_string(); } @@ -1244,8 +1244,8 @@ pub fn launch_tool(stdout: &mut Stream, args: &[String], tool_name: &str, defaul if let Some(ArgumentValue::ArgString(f, content)) = parsed_args.get("path_or_code") { match read_ir(content) { Ok(s) => { - input_program = content.clone(); - input_file = f.clone(); + input_program.clone_from(content); + input_file.clone_from(f); src_sexp = s; } Err(e) => { diff --git a/src/classic/clvm_tools/stages/stage_2/optimize.rs b/src/classic/clvm_tools/stages/stage_2/optimize.rs index 9aef8e77c..c3c7d2fa7 100644 --- a/src/classic/clvm_tools/stages/stage_2/optimize.rs +++ b/src/classic/clvm_tools/stages/stage_2/optimize.rs @@ -688,7 +688,7 @@ pub fn optimize_sexp_( } SExp::Pair(_, _) => { for opt in optimizers.iter() { - name = opt.name.clone(); + name.clone_from(&opt.name); match opt.invoke(allocator, memo, r, eval_f.clone()) { Err(e) => { return Err(e); diff --git a/src/classic/platform/argparse.rs b/src/classic/platform/argparse.rs index 916d1343f..eea96c176 100644 --- a/src/classic/platform/argparse.rs +++ b/src/classic/platform/argparse.rs @@ -491,10 +491,7 @@ impl ArgumentParser { } let name = &self.optional_args[k].names[index as usize]; - let index2 = match arg.find(name) { - Some(i) => i, - _ => 0, - } + name.len(); + let index2 = arg.find(name).unwrap_or_default() + name.len(); let value = &arg[index2..].to_string(); norm.push(name.to_string()); diff --git a/src/compiler/codegen.rs b/src/compiler/codegen.rs index af3fcb4c9..08d695827 100644 --- a/src/compiler/codegen.rs +++ b/src/compiler/codegen.rs @@ -1520,7 +1520,7 @@ fn start_codegen( )), }; - code_generator.to_process = program.helpers.clone(); + code_generator.to_process.clone_from(&program.helpers); // Ensure that we have the synthesis of the previous codegen's helpers and // The ones provided with the new form if any. let mut combined_helpers_for_codegen = program.helpers.clone(); @@ -1716,7 +1716,9 @@ pub fn codegen( // If stepping 23 or greater, we support no-env mode. enable_nil_env_mode_for_stepping_23_or_greater(opts.clone(), &mut code_generator); - *context.symbols() = code_generator.function_symbols.clone(); + context + .symbols() + .clone_from(&code_generator.function_symbols); context .symbols() .insert("source_file".to_string(), opts.filename()); diff --git a/src/compiler/compiler.rs b/src/compiler/compiler.rs index cce5566d8..7b8a9bb27 100644 --- a/src/compiler/compiler.rs +++ b/src/compiler/compiler.rs @@ -222,7 +222,7 @@ impl CompilerOpts for DefaultCompilerOpts { } fn set_search_paths(&self, dirs: &[String]) -> Rc { let mut copy = self.clone(); - copy.include_dirs = dirs.to_owned(); + dirs.clone_into(&mut copy.include_dirs); Rc::new(copy) } fn set_disassembly_ver(&self, ver: Option) -> Rc { diff --git a/src/compiler/comptypes.rs b/src/compiler/comptypes.rs index 8ba656dbf..af9f4840e 100644 --- a/src/compiler/comptypes.rs +++ b/src/compiler/comptypes.rs @@ -1227,7 +1227,7 @@ pub fn join_vecs_to_string(sep: Vec, vecs: &[Vec]) -> String { s.append(&mut comma.clone()); s.append(&mut elt.to_vec()); if comma.is_empty() { - comma = sep.clone(); + comma.clone_from(&sep); } }