diff --git a/Cargo.toml b/Cargo.toml index 4781c95e1..41432a98b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -378,6 +378,7 @@ use_self = "warn" useless_let_if_seq = "warn" # pedantic lints to enforce gradually +assigning_clones = "warn" bool_to_int_with_if = "warn" checked_conversions = "warn" cloned_instead_of_copied = "warn" diff --git a/crates/codegen/src/compile.rs b/crates/codegen/src/compile.rs index 711ac3926..c63647f61 100644 --- a/crates/codegen/src/compile.rs +++ b/crates/codegen/src/compile.rs @@ -2073,7 +2073,7 @@ impl<'warnings> Compiler<'warnings> { fn expose_annotation_format_parameter(code: &mut CodeObject) { if let Some(first) = code.varnames.first_mut() { - *first = "format".to_owned(); + *first = String::from("format"); } } diff --git a/crates/codegen/src/symboltable.rs b/crates/codegen/src/symboltable.rs index a78b49a6e..a72b839f4 100644 --- a/crates/codegen/src/symboltable.rs +++ b/crates/codegen/src/symboltable.rs @@ -1632,8 +1632,9 @@ impl SymbolTableBuilder { } if type_params.is_none() { - self.class_name = prev_class.clone(); + self.class_name.clone_from(&prev_class); } + if let Some(arguments) = arguments { self.scan_expressions(&arguments.args, ExpressionContext::Load)?; for keyword in &arguments.keywords { diff --git a/crates/vm/src/getpath.rs b/crates/vm/src/getpath.rs index 38aa122db..634547201 100644 --- a/crates/vm/src/getpath.rs +++ b/crates/vm/src/getpath.rs @@ -121,7 +121,7 @@ pub fn init_path_config(settings: &Settings) -> Paths { // - sys.executable should be the launcher path (where user invoked Python) // - sys._base_executable should be the real Python executable let exe_dir = if let Ok(launcher) = crate::host_env::os::var("__PYVENV_LAUNCHER__") { - paths.executable = launcher.clone(); + paths.executable.clone_from(&launcher); paths.base_executable = real_executable; PathBuf::from(&launcher).parent().map(PathBuf::from) } else { @@ -152,7 +152,7 @@ pub fn init_path_config(settings: &Settings) -> Paths { paths.base_prefix = calculated_prefix; } else { // Not in venv: prefix == base_prefix - paths.prefix = calculated_prefix.clone(); + paths.prefix.clone_from(&calculated_prefix); paths.base_prefix = calculated_prefix; } @@ -163,7 +163,7 @@ pub fn init_path_config(settings: &Settings) -> Paths { } else { calculate_exec_prefix(search_dir.as_ref(), paths.prefix.as_ref()) }; - paths.base_exec_prefix = paths.base_prefix.clone(); + paths.base_exec_prefix.clone_from(&paths.base_prefix); // Step 7: Calculate base_executable (if not already set by __PYVENV_LAUNCHER__) if paths.base_executable.is_empty() { diff --git a/crates/vm/src/vm/vm_new.rs b/crates/vm/src/vm/vm_new.rs index 2c053bdf8..c71cf8425 100644 --- a/crates/vm/src/vm/vm_new.rs +++ b/crates/vm/src/vm/vm_new.rs @@ -794,10 +794,10 @@ impl VirtualMachine { }; if syntax_error_type.is(self.ctx.exceptions.tab_error) { - syntax_error_info.msg = "inconsistent use of tabs and spaces in indentation".to_owned(); - } - if syntax_error_type.is(self.ctx.exceptions.incomplete_input_error) { - syntax_error_info.msg = "incomplete input".to_owned(); + syntax_error_info.msg = + String::from("inconsistent use of tabs and spaces in indentation"); + } else if syntax_error_type.is(self.ctx.exceptions.incomplete_input_error) { + syntax_error_info.msg = String::from("incomplete input"); } let SyntaxErrorInfo { msg, narrow_caret } = syntax_error_info;