mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 00:41:15 -03:00
clippy: fix assigning_clones lint
https://rust-lang.github.io/rust-clippy/master/index.html#assigning_clones Closes #12267
This commit is contained in:
committed by
Johannes Altmanninger
parent
400d5281f4
commit
06a14c4a76
@@ -184,6 +184,7 @@ rust.unstable_name_collisions = "allow"
|
||||
rustdoc.private_intra_doc_links = "allow"
|
||||
|
||||
[workspace.lints.clippy]
|
||||
assigning_clones = "warn"
|
||||
implicit_clone = "warn"
|
||||
cloned_instead_of_copied = "warn"
|
||||
len_without_is_empty = "allow" # we're not a library crate
|
||||
|
||||
@@ -890,7 +890,7 @@ fn new_var_values(
|
||||
// So do not use the given variable: we must re-fetch it.
|
||||
// TODO: this races under concurrent execution.
|
||||
if let Some(existing) = vars.get(varname) {
|
||||
result = existing.as_list().to_owned();
|
||||
existing.as_list().clone_into(&mut result);
|
||||
}
|
||||
|
||||
if opts.prepend {
|
||||
@@ -914,10 +914,12 @@ fn new_var_values_by_index(split: &SplitVar, argv: &[&wstr]) -> Vec<WString> {
|
||||
// Inherit any existing values.
|
||||
// Note unlike the append/prepend case, we start with a variable in the same scope as we are
|
||||
// setting.
|
||||
let mut result = vec![];
|
||||
if let Some(var) = split.var.as_ref() {
|
||||
result = var.as_list().to_owned();
|
||||
}
|
||||
let mut result = split
|
||||
.var
|
||||
.as_ref()
|
||||
.map(EnvVar::as_list)
|
||||
.unwrap_or_default()
|
||||
.to_owned();
|
||||
|
||||
// For each (index, argument) pair, set the element in our `result` to the replacement string.
|
||||
// Extend the list with empty strings as needed. The indexes are 1-based.
|
||||
|
||||
@@ -281,7 +281,7 @@ fn merge(&mut self, item: &HistoryItem) -> bool {
|
||||
// Ok, merge this item.
|
||||
self.creation_timestamp = self.creation_timestamp.max(item.creation_timestamp);
|
||||
if self.required_paths.len() < item.required_paths.len() {
|
||||
self.required_paths = item.required_paths.clone();
|
||||
self.required_paths.clone_from(&item.required_paths);
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ fn infinite_recursive_statement_in_job_list<'b>(
|
||||
});
|
||||
|
||||
if infinite_recursive_statement.is_some() {
|
||||
*out_func_name = forbidden_function_name.to_owned();
|
||||
forbidden_function_name.clone_into(out_func_name);
|
||||
}
|
||||
|
||||
// may be none
|
||||
@@ -1865,7 +1865,7 @@ fn setup_group(&self, ctx: &OperationContext<'_>, j: &mut Job) {
|
||||
.is_some_and(|job_group| job_group.has_job_id() || !j.wants_job_id())
|
||||
&& !j.is_initially_background()
|
||||
{
|
||||
j.group = ctx.job_group.clone();
|
||||
j.group.clone_from(&ctx.job_group);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user