mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 20:31:19 -03:00
clippy: fix implicit_clone lint
https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone Closes #12245
This commit is contained in:
committed by
Johannes Altmanninger
parent
41b9584bb3
commit
2d6db3f980
@@ -184,6 +184,7 @@ rust.unstable_name_collisions = "allow"
|
||||
rustdoc.private_intra_doc_links = "allow"
|
||||
|
||||
[workspace.lints.clippy]
|
||||
implicit_clone = "warn"
|
||||
cloned_instead_of_copied = "warn"
|
||||
len_without_is_empty = "allow" # we're not a library crate
|
||||
let_and_return = "allow"
|
||||
|
||||
@@ -196,7 +196,7 @@ fn parse_exclusive_args(opts: &mut ArgParseCmdOpts, streams: &mut IoStreams) ->
|
||||
}
|
||||
|
||||
// Store the set of exclusive flags for use when parsing the supplied set of arguments.
|
||||
opts.exclusive_flag_sets.push(exclusive_set.to_vec());
|
||||
opts.exclusive_flag_sets.push(exclusive_set.clone());
|
||||
}
|
||||
Ok(SUCCESS)
|
||||
}
|
||||
|
||||
@@ -370,8 +370,8 @@ fn insert(
|
||||
if self.add(
|
||||
seq,
|
||||
&argv[optind + 1..],
|
||||
self.opts.bind_mode.to_owned(),
|
||||
self.opts.sets_bind_mode.to_owned(),
|
||||
self.opts.bind_mode.clone(),
|
||||
self.opts.sets_bind_mode.clone(),
|
||||
self.opts.user,
|
||||
streams,
|
||||
) {
|
||||
|
||||
@@ -295,7 +295,7 @@ fn populate_captures_from_match<'a>(
|
||||
// empty/null members so we're going to have to use an empty string as the
|
||||
// sentinel value.
|
||||
|
||||
if let Some(m) = cg.as_ref().and_then(|cg| cg.name(&name.to_string())) {
|
||||
if let Some(m) = cg.as_ref().and_then(|cg| cg.name(&name.clone())) {
|
||||
captures.push(WString::from(m.as_bytes()));
|
||||
} else if opts.all {
|
||||
captures.push(WString::new());
|
||||
|
||||
@@ -862,7 +862,7 @@ fn test_universal() {
|
||||
let mut handles = Vec::new();
|
||||
|
||||
for i in 0..threads {
|
||||
let path = test_path.to_owned();
|
||||
let path = test_path.clone();
|
||||
handles.push(std::thread::spawn(move || {
|
||||
test_universal_helper(i, &path);
|
||||
}));
|
||||
@@ -873,7 +873,7 @@ fn test_universal() {
|
||||
}
|
||||
|
||||
let mut uvars = EnvUniversal::new();
|
||||
uvars.initialize_at_path(test_path.to_owned());
|
||||
uvars.initialize_at_path(test_path.clone());
|
||||
|
||||
for i in 0..threads {
|
||||
for j in 0..UVARS_PER_THREAD {
|
||||
@@ -1037,11 +1037,11 @@ fn test_universal_callbacks() {
|
||||
let mut uvars1 = EnvUniversal::new();
|
||||
let mut uvars2 = EnvUniversal::new();
|
||||
let mut callbacks = uvars1
|
||||
.initialize_at_path(test_path.to_owned())
|
||||
.initialize_at_path(test_path.clone())
|
||||
.unwrap_or_default();
|
||||
callbacks.append(
|
||||
&mut uvars2
|
||||
.initialize_at_path(test_path.to_owned())
|
||||
.initialize_at_path(test_path.clone())
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
|
||||
@@ -1134,7 +1134,7 @@ fn test_universal_ok_to_save() {
|
||||
|
||||
let mut uvars = EnvUniversal::new();
|
||||
uvars
|
||||
.initialize_at_path(test_path.to_owned())
|
||||
.initialize_at_path(test_path.clone())
|
||||
.unwrap_or_default();
|
||||
assert!(!uvars.is_ok_to_save(), "Should not be OK to save");
|
||||
uvars.sync();
|
||||
|
||||
@@ -737,7 +737,7 @@ fn expand_variables(
|
||||
// here, So tmp < 1 means it's definitely not in.
|
||||
// Note we are 1-based.
|
||||
if item_index >= 1 && item_index <= all_var_items.len() {
|
||||
var_item_list.push(all_var_items[item_index - 1].to_owned());
|
||||
var_item_list.push(all_var_items[item_index - 1].clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1038,7 +1038,7 @@ pub fn expand_cmdsubst(
|
||||
continue;
|
||||
}
|
||||
// -1 to convert from 1-based slice index to 0-based vector index.
|
||||
sub_res2.push(sub_res[idx as usize - 1].to_owned());
|
||||
sub_res2.push(sub_res[idx as usize - 1].clone());
|
||||
}
|
||||
sub_res = sub_res2;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ pub fn test_path(&self, token: &wstr, prefix: bool) -> bool {
|
||||
is_potential_path(
|
||||
&token,
|
||||
prefix,
|
||||
&[self.working_directory.to_owned()],
|
||||
std::slice::from_ref(&self.working_directory),
|
||||
self.ctx,
|
||||
PathFlags {
|
||||
expand_tilde: true,
|
||||
|
||||
@@ -451,7 +451,7 @@ fn compact_new_items(&mut self) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if !seen.insert(item.contents.to_owned()) {
|
||||
if !seen.insert(item.contents.clone()) {
|
||||
// This item was not inserted because it was already in the set, so delete the item at
|
||||
// this index.
|
||||
self.new_items.remove(idx);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
pub fn path_get_config() -> Option<WString> {
|
||||
let dir = get_config_directory();
|
||||
if dir.success() {
|
||||
Some(dir.path.to_owned())
|
||||
Some(dir.path.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -40,7 +40,7 @@ pub fn path_get_config() -> Option<WString> {
|
||||
pub fn path_get_data() -> Option<WString> {
|
||||
let dir = get_data_directory();
|
||||
if dir.success() {
|
||||
Some(dir.path.to_owned())
|
||||
Some(dir.path.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -57,7 +57,7 @@ pub fn path_get_data() -> Option<WString> {
|
||||
pub fn path_get_cache() -> Option<WString> {
|
||||
let dir = get_cache_directory();
|
||||
if dir.success() {
|
||||
Some(dir.path.to_owned())
|
||||
Some(dir.path.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -5989,14 +5989,10 @@ fn reader_run_command(parser: &Parser, cmd: &wstr) -> EvalRes {
|
||||
|
||||
// Provide values for `status current-command` and `status current-commandline`
|
||||
if !ft.is_empty() {
|
||||
parser.libdata_mut().status_vars.command = ft.to_owned();
|
||||
parser.libdata_mut().status_vars.command = ft.clone();
|
||||
parser.libdata_mut().status_vars.commandline = cmd.to_owned();
|
||||
// Also provide a value for the deprecated fish 2.0 $_ variable
|
||||
parser.set_one(
|
||||
L!("_"),
|
||||
ParserEnvSetMode::new(EnvMode::GLOBAL),
|
||||
ft.to_owned(),
|
||||
);
|
||||
parser.set_one(L!("_"), ParserEnvSetMode::new(EnvMode::GLOBAL), ft.clone());
|
||||
}
|
||||
|
||||
reader_write_title(cmd, parser, true);
|
||||
|
||||
@@ -500,7 +500,7 @@ pub fn new(
|
||||
working_directory,
|
||||
completion_set: resolved_completions
|
||||
.iter()
|
||||
.map(|c| c.completion.to_owned())
|
||||
.map(|c| c.completion.clone())
|
||||
.collect(),
|
||||
visited_files: HashSet::new(),
|
||||
flags,
|
||||
@@ -943,7 +943,7 @@ fn descend_unique_hierarchy(&mut self, start_point: &mut WString) -> WString {
|
||||
break;
|
||||
} else if entry.is_dir() && unique_entry.is_empty() {
|
||||
// first candidate
|
||||
unique_entry = entry.name.to_owned();
|
||||
unique_entry = entry.name.clone();
|
||||
} else {
|
||||
// We either have two or more candidates, or the child is not a directory. We're
|
||||
// done.
|
||||
|
||||
Reference in New Issue
Block a user